ChatMessageEventArgs
Namespace: Wisej.Web.Ext.Syncfusion2
Assembly: Wisej.Web.Ext.Syncfusion2 (4.1.0.0)
Provides access to the outgoing chat message before the wrapper commits it on the client.
- C#
- VB.NET
public class ChatMessageEventArgs : ChatCancelableEventArgs
Public Class ChatMessageEventArgs
Inherits ChatCancelableEventArgs
Constructors
ChatMessageEventArgs(message, cancel, name, data)
Initializes a new instance of the ChatMessageEventArgs class.
| Name | Type | Description |
|---|---|---|
| message | ChatMessage | The outgoing message. |
| cancel | Boolean | The initial value of Cancel. |
| name | String | The name of the client event, normally messageSend. |
| data | Object | The raw event data received from the browser, or null. |
Example:
The following example, placed in a class derived from Chat, raises MessageSend for a message created on the server.
var message = new ChatMessage { Author = this.User, Text = "Hello" };
var args = new ChatMessageEventArgs(message, false, "messageSend", null);
this.OnMessageSend(args);
if (!args.Cancel)
this.AddMessage(args.Message);
Properties
Message
ChatMessage: Gets or sets the message that the user is sending.
The message carries the text typed in the composer, the users selected in the mention popup (MentionUsers, referenced in Text by the placeholders {0}, {1}, ...) and the uploaded attachment (AttachedFile).
After the MessageSend handlers return, the message assigned to this property is the one that the control completes and appends to Messages. Replacing the instance, or changing its fields, does not change the message already displayed in the browser; call UpdateMessage afterwards for that.
Example:
The following example reads the message that was sent and the names of the mentioned users.
chat.MessageSend += (s, e) =>
{
Chat.ChatMessage message = e.Message;
if (message == null)
return;
string mentioned = message.MentionUsers == null
? ""
: String.Join(", ", message.MentionUsers.Select(u => u?.User));
AlertBox.Show($"{message.Author?.User}: {message.Text} (mentions: {mentioned})");
};