Listen to events

Profile, participants, and typing events are not managed with store implementation and the app should register appropriate listeners for relevant events.

You can register listeners from client instance:

/* add events listener:
 * ProfileListener - changes to user profile details
 * ParticipantsListener - changes to participant list in conversation
 * TypingListener - user started/stopped typing in a conversation
 */
client.addListener(listener);

// remove events listener
client.removeListener(listener);

or set them up in a configuration when initialising:

ComapiConfig config = new ComapiConfig()
   .participantsListener(listener /* extends ParticipantsListener */)
   .profileListener(listener /* extends ProfileListener */)
   .typingListener(listener /* extends TypingListeners */);

Listeners classes are abstract with empty implementation of onEventName methods. You can override some or all of them to receive socket events from the foundation SDK.

Real-time events are available only when the application is in the foreground; visible to the user. If the app is put to the background, you can use FCM to communicate messages to the user and update the internal state after the app is put back to foreground using services APIs.


Available events

Event NameDescription
ProfileUpdateEventSent when a user's profile is updated.
ParticipantAddedEventSent when a participant is added to a conversation. When a conversation is created, this event also fires with the owner's profileId.
ParticipantUpdatedEventSent when a participant role is updated in a conversation.
ParticipantRemovedEventSent when a participant is removed from a conversation.
ParticipantTypingEventSent when the isTyping method has been called, informing conversation participants that the user started typing a new message.
ParticipantTypingOffEventSent when the isTyping method has been called, informing conversation participants that the user stopped typing a new message.
// event unique identifier
getEventId()

// event name/type
getName()

and the specific event types also provide:

// profile unique identifier
getProfileId();

// time when the update event was published
getPublishedOn();

// revision of the profile details on the server
getRevision();

// gets profileId of an user that performed this update
getCreatedBy();

// gets profile update details
getPayload();

// tag specifying server data version
getETag();
// conversation unique identifier
getConversationId();

// profile unique identifier
getProfileId();

// role definition for this participant in this conversation
getRole();
// Same as ParticipantAddedEvent
// Same as ParticipantAddedEvent
// conversation unique identifier
getConversationId();

// get profile id of an participant who started typing a new message
getProfileId();
// conversation unique identifier
getConversationId();

// get profile id of an participant who stopped typing a new message
getProfileId();