Mesibo Presence APIs - Online Status, Typing Indicators, and more
Mesibo presence APIs allow your active users to share their activities, for example, online and offline status, typing indicator, joining and leaving the chat, game actions, etc. as it happens in real-time. Although sending and receiving presence information is completely optional, it can greatly enhance chat engagement.
Note that, presence messages are never stored and only delivered to online users.
You can define and send different types of presence messages to meet your app requirements. Mesibo also has some pre-defined presence messages, as described below.
Sending a Presence Message
You can send a presence message by creating MesiboPresence
object or directly calling the helper function from MesiboProfile
object. For example, to send typing indicator
MesiboPresence presence = profile.createPresence();
presence.sendTyping();
or, just by using the helper function from MesiboProfile
,
profile.sendTyping();
On the receiving side, Mesibo_onPresence
function in the MesiboPresenceListener
listener will be called with the presence information.
void Mesibo_onPresence(MesiboPresence presence) {
}
Pre-Defined Presence Messages
Typing Indicators
A user can show he or she is typing or has stopped typing to other users or group members by sending Typing Activities. On the receiving end, UI can show typing indicator, typically by showing a showing "typing" or "User is Typing" below the username. However, it is entirely up to your app how to show it.
profile.sendTyping();
Join and left Indicators
A user can also show that he or she has joined or left the conversation by sending JOIN or LEFT presence
profile.sendJoined();
and,
profile.sendLeft();
Sending Custom Presence
You can also define the custom presence and send it using the send
function of MesiboPresence
class
int send(int presence);
int send(int presence, int value, int interval);
where,
Parameter | Description |
---|---|
presence | Any integer value larger than 1000 |
value | Optional, any integer value |
interval | Optional, the interval in milliseconds. The presence will not be sent if the same presence was sent during this interval |
For example,
MesiboPresence presence = profile.createPresence();
presence.send(1001);
Online and Offline Status
A user can show his or her Online and Offline Status to other users or group members by sending Online and Offline activities. On the receiving end, UI can show online status, typically by showing a green dot or by showing the text Online
below the username. However, it is entirely up to your app how to show it.
Note, you generally do not need to send Online and Offline activities as mesibo can automatically send them for you. You only need to configure when to show online status and privacy. We will describe that in detail in the next section.