Event object
An object that refers to a single piece of information emitted when someone is typing, receiving a message, mentioning others in a message, or reporting a message/user to the admin.
Contrary to other Chat SDK entities, this object provides no methods. Its only purpose is to pass payloads of different types emitted when certain chat operations occur.
Properties
The Event
interface has the following properties:
public protocol Event<T> {
associatedtype C: Chat
associatedtype T: EventContent
var chat: C { get }
var timetoken: Timetoken { get }
var payload: T { get }
var channelId: String { get }
var userId: String { get }
}
Parameter | Type | Description |
---|---|---|
chat | C | Reference to the main ChatImpl object. |
timetoken | Timetoken | Timetoken of the message that triggered an event. |
payload | T | Data passed in an event (of EventContent subtype) that differ depending on the emitted event type (Typing , Report , Receipt , Mention , Invite , Custom , or Moderation ). |
channelId | String | Target channel where this event is delivered. |
userId | String | Unique ID of the user that triggered the event. |
Use case
You can use events to collect historical chat events or create your own custom events. You can later visualize them in a graphical form (like a moderation dashboard for flagged users and messages) or create additional business logic with functions that these events can trigger.