MsgCommunicator: Delphi Instant Messaging (IM) SDK
for easy creation of custom messenger system


TMsgServer.OnSaveMessage
TMsgServer
Top 

Occurs before saving message to database.

type TMsgOnSaveMessage = procedure (
const SenderID: Cardinal;
const RecipientID: Cardinal;
const MessageType: TMsgMessageType;
const SendingDate: TDateTime;
const DeliveryDate: TDateTime;
const MessageData: PChar;
const MessageDataSize: Integer;
var MessageText: String;
var MessageUnicodeText: WideString;
const Command: Cardinal
) of object;

property
OnSaveMessage: TMsgOnSaveMessage;

Description
Use OnSaveMessage to customize text and / or Unicode text of the message before saving it to the database.
If Database is not set or StoreMessageHistory is set to false, OnSaveMessage will not be triggered.

Even if message is not a text message (binary or stream message or custom command), you can assign text or Unicode text to it.
Thus, you will be able to search all types of messages in message history, including binary messages and custom commands.

SenderID - UserID of the user who sends the message or ServerID if message was sent from server.
RecipientID - UserID of the user who receives the message or ServerID if message was sent to server.
MessageType - type of the message.
SendingDate - date and time when messages was sent. If message sent to server or message is sent to user directly (peer to peer), SendingDate will be set to sender's date and time. If message sent to user through the server, SendingDate will be set to server's date and time (when message was received by server from sender).
DeliveryDate - date and time on recipient's machine when message was delivered.
MessageData - pointer to buffer with message data if message is binary or stream, otherwise MessageData is set to nil.
MessageDataSize - size of binary data in MessageData, zero if MessageData is set to nil.
MessageText - text of the message. If message type is not text, then MessageText is set to empty string. You can change MessageText for any message.
MessageUnicodeText - Unicode text of the message. MessageUnicodeText is always set to empty string. You can change MessageUnicodeText for any message.
Command - custom command, sent by SendCommand.

All parameters of OnSaveMessage will be inserted to messages table of the Database, assoicated with this TMsgServer (server history).

Note:   If you need to store Unicode text of the messages, check your database specification. The database with message history must support Unicode. Accuracer Database System supports Unicode, while MySQL does not.


© AidAim Software MsgCommunicator: Delphi Messenger Sdk Instant Messaging Sdk Im Sd