timeToLivefield which indicates the time in seconds up to which a presence is valid. After the time has elapsed, the user presence automatically shifts to the next presence in line (if any).
Presenceobject, to begin with. Therefore, let’s build one:
PresenceBuilderto build a cascading presence in a fluent manner. In a nutshell, the user’s presence begins with
Onlinethen shifts to
Awayafter 15 seconds and so on.
Presenceobject, you can choose either the manual approach or the automatic one for updating. It’s recommended that you use the automatic approach as it’s less management work for you.
startAutoUpdateCurrentUserPresence()method on the
Online. Once the user exits your app, it stops polling and as a result, the presence starts expiring to the next status as discussed earlier.
Note: Here, the second argument value is the polling interval (in secs). Therefore, this example sets polling every 5 seconds.
setCurrentUserPresence()method on the
Usersobject. Something like this:
Note: This is a one-shot update call. If you don’t make this call periodically, the current user’s presence will shift to the next expiring presence after the
timeToLivehas elapsed, even if your app is open.
getUserPresence()method on the
SentTimetimeline event to every message you sent.
mitter.mtet.SentTime- The time at which the message was sent
mitter.mtet.ReceivedTime- The time at which the message was received by the server
mitter.mtet.DeliveredTime- The time at which the message was delivered to the user
mitter.mtet.ReadTime- The time at which the message was read by the user
mitter.mtet.ReadTimeevents where you don’t have to set these types explicitly. You’ll see how.
addReadTimelineEvent()method on the
Messagingobject. Here’s a quick demo:
onValueUpdatedCallback, if you want to be notified after the operation has succeeded.
addTimelineEvent()method to add a timeline event to your messages. This method accepts a
TimelineEventobject which you need to construct on your own, fully customised to your needs.
TimelineEventobject with some required parameters, as follows:
typeis the type of the event that you’re sending,
eventTimeMsis the timestamp you want to associate with the event and the
subjectis the user with whom this event should be associated.
subjectwould the receiving user who has read the message.
addTimelineEvent()method and supplying the
TimelineEventobject that you created in the previous step. This is how the code looks:
addReadTimelineEvent()method with the exception that it accepts a
TimelineEventobject without assuming anything on it’s own.