Event object
Event represents a single piece of information emitted during chat operations: typing indicators, message receipts, mentions, or reports.
Unlike other Chat SDK entities, Event provides no methods - it only passes payloads emitted during chat operations.
Properties
ChatEvent has the following properties:
1public struct ChatEvent
2{
3 public string TimeToken;
4 public PubnubChatEventType Type;
5 public string ChannelId;
6 public string UserId;
7 public string Payload;
8}
| Parameter | Description |
|---|---|
TimeTokenType: string | Timetoken of the message that triggered an event. |
TypeType: PubnubChatEventType | Type of action that emits an event: Typing, Report, Receipt, Mention, Invite, Custom, and Moderation. |
ChannelIdType: string | Target channel where this event is delivered. |
UserIdType: string | Unique ID of the user that triggered the event. |
PayloadType: string | Data passed in an event that differ depending on the event type. |
For details, refer to the chat events documentation.
Typed event data
Streaming methods on entities deliver typed data structs instead of raw ChatEvent objects. The following typed event structs are available:
1public struct Invite
2{
3 public string ChannelId;
4 public string ChannelType;
5 public string InvitedByUserId;
6 public string Timetoken;
7}
8
9public struct Mention
10{
11 public string Text;
12 public string MessageTimetoken;
13 public string ChannelId;
14 public string? ParentChannelId;
15 public string MentionedByUserId;
show all 32 lines| Struct | Used by | Description |
|---|---|---|
Invite | User.OnInvited | Delivered when a user is invited to a channel. Contains the channel ID, channel type, inviter user ID, and timetoken. |
Mention | User.OnMentioned | Delivered when a user is mentioned. Contains the message text, timetoken, channel, optional parent channel (for threads), and the mentioner's user ID. |
MessageReport | Channel.OnMessageReported | Delivered when a message is reported. Contains the reason, text, timetoken, channel, reported user, and optional auto-moderation ID. |
ReadReceipt | Channel.OnReadReceiptEvent | Delivered when a read receipt is received. Contains the user ID and last read timetoken. |
Use case
Events enable:
- Collecting historical chat events
- Creating custom events
- Building moderation dashboards for flagged messages
- Triggering business logic with Functions