Websocket events

Events

Realtime events are delivered to the SDK via a web-socket. These events can be subscribed to via the following methods ...

Subscribe to an event

sdk.on("profileUpdated", function (event) {
    console.log("profileUpdated", event);
});

Unsubscribe from an event

sdk.off("profileUpdated");

Complete list of events

Event NameEvent PayloadDescription
conversationDeletedIConversationDeletedEventDataSent when a conversation is deleted
conversationUndeletedIConversationUndeletedEventDataSent when a conversation is undeleted
conversationUpdatedIConversationUpdatedEventDataSent when a conversation is updated
participantAddedIParticipantAddedEventDataSent when a participant is added to a conversation. When a conversation is created, this event will also fire with the owner's profileId.
participantRemovedIParticipantRemovedEventDataSent when a participant is removed to a conversation. App needs to check whether the participant is the current user and locally remove the conversation from the UI.
participantTypingIParticipantTypingEventDataSent when a participant is typing in a conversation
profileUpdatedIProfileUpdatedEventSent when a user's profile is updated
conversationMessageEventIConversationMessageEventThis event is sent for all conversation message related activity. It encapsulates the sent, delivered and read events. It is defined like this so you can handle web-socket conversation message events and events requested from sdk.services.appMessaging.getConversationEvents() seamlessly.

IConversationDeletedEventData

export interface IConversationDeletedEventData {
    conversationId: string;
    createdBy: string;
    timestamp: string;
}      

IConversationUndeletedEventData

export interface IConversationUndeletedEventData {
    conversationId: string;
    createdBy: string;
    timestamp: string;
}      

IConversationUpdatedEventData

export interface IConversationUpdatedEventData {
    conversationId: string;
    createdBy: string;
    name: string;
    description: string;
    roles: IConversationRoles;
    isPublic: boolean;
    timestamp: string;
}      

IParticipantAddedEventData

export interface IParticipantAddedEventData {
    conversationId: string;
    createdBy: string;
    profileId: string;
    role: string;
    timestamp: string;
}

IParticipantRemovedEventData

export interface IParticipantRemovedEventData {
    conversationId: string;
    createdBy: string;
    profileId: string;
    timestamp: string;
}

IParticipantTypingEventData

export interface IParticipantTypingEventData {
    conversationId: string;
    createdBy: string;
    profileId: string;
    timestamp: string;
}

IProfileUpdatedEvent

export interface IProfileUpdatedEvent {
    eTag: string;
    profile: any;
}

IConversationMessageEvent

This event encapsulates sent, delivered and read events.

export interface IConversationMessageEvent {
    eventId: string;
    // name field will be ["conversationMessage.sent" | "conversationMessage.read" | "conversationMessage.delivered"]
    name: string;
    conversationId: string;
    conversationEventId: number;
    // payload will differ based on event name ...
    payload: IMessageSentPayload | IMessageStatusUpdatePayload;
}

// payload for conversationMessage.sent
export interface IMessageSentPayload {
    messageId: string;
    metadata: any;
    context: any;
    parts: IMessagePart[];
    alert: IMessageAlert;
}

// payload for conversationMessage.delivered, conversationMessage.read
export interface IMessageStatusUpdatePayload {
    messageId: string;
    conversationId: string;
    profileId: string;
    timestamp: string;
}