TRVChat.InsertMessage

<< Click to display table of contents >>

TRVChat.InsertMessage

The methods insert a new message at the position specified by Index. Two methods with the same functionality, differing only in how parameters are passed directly or via a record.

function InsertMessage(AIndex: Integer;

  AUser: TRVChatUser

  const AText: TRVUnicodeString;
  ADateTime: TDateTime = 0; 

  Extra: TRVChatMessageExtra = nil;
  AState: TRVChatMessageState = rvcmsDefault): 

  TRVChatMessage
 

function InsertMessage(AIndex: Integer;
  const Data: TRVChatMessageInsertionInfo):

  TRVChatMessage

These methods are rarely used, since messages are usually added with AddMessage.

Possible usage scenarios: a chat client receives messages in a different order than they were written and wants to arrange them by time of writing. Potential Messages[] fields that can be used to determine the order of messages are DateTime and GlobalIndex.

The methods update both the content of ChatRichView and insert an item in Messages.

The methods expect ChatRichView to be formatted before they are called. They format the added message.

Parameters

AIndex specifies the position of message insertion, in range from 0 to Messages.Count.

AUser – a reference to the user (the author of this message). This is a reference to one of items in Users.

AText – message text. If (Extra = nil) or (Extra is TRVChatMessageExtraQuote), AText cannot be empty. AText can be multi-line.

ADateTime – message time. If 0, the current time is used.

Extra – additional data attached to the message: files, an image, or a quote. It may be an object the following classes:

TRVChatMessageExtraFiles to attach files

TRVChatMessageExtraImage to attach an image

TRVChatMessageExtraQuote to add a quotation

nil to attach nothing.

If Extra.AutoDestroy = True, this method frees Extra (if the message was added successfully)

AState – message status.

Return value

A reference to the appended message on success; nil otherwise.