Events: retransmit
This article will teach you how to retransmit events and why you need it.
Contents
What is event retransmission
Each action in a Voximplant conversation is represented by events. This includes sending, receiving, and editing messages; adding and removing participants, changing user permissions and conversation preferences, and much more.
When a user is logged in to the conversation, the user tracks these events via event listeners. But when a user is logged off, the user cannot track any events.
That is why, when you log a user into a conversation, you need to retransmit events to update previous messages and other conversation changes.
How to retransmit events
In WebSDK, use the retransmitEvents method to retransmit up to 100 previous events.
In the iOS SDK, use the following methods to retransmit events:
In the Android SDK, use the following methods as well:
Please refer to the given API reference links to learn more about these methods.
Here is a code example of how to retransmit events in Web, iOS and Android SDKs:
The retransmitEvents method requires two parameters: to and count.
The to parameter's value equals the conversation's lastSequence property, and the count parameter's value is an integer that represents the number of events.
Download our demos
Here you can download our instant messaging demos for multiple platforms for your instance:
Frequently asked questions
Q: Can the toCache/fromCache help me get the chat history?
A: The toCache/fromCache methods, such as toCache/createConversationFromCache for conversations can help you to create a json-friendly object to save in your application storage and restore the conversation from the object. However, you need to implement the storage logic for this object yourself, and restoring the conversation from the saved object does not request the recent activity from the Voximplant servers. You need to request the recent activity via the retransmitEvents method to update the conversation.