A like feature in live-streaming apps enhances viewer engagement. It creates a more dynamic and interactive environment. As users express their appreciation for content through likes, it is essential to ensure a smooth and friendly experience. However, high-frequency interactions can put significant pressure on the business server. This potentially leads to lag or interruptions in the streaming experience.
To address this challenge, ZEGOCLOUD provides a solution for managing the send-like operations. Collecting and aggregating interactions before reporting reduces server load. This maintains real-time interactivity in the process. This approach not only improves performance but also fosters a vibrant community within the streaming platform. This guide explores strategies for developing a robust send-likes feature. It helps ensure your app thrives in a competitive market.
How Does Sending-Like Work?
To manage the sending-likes process, the following flow chart outlines the implementation steps for effective execution.
- When a viewer clicks the like button, the app plays the like animation locally. It also updates the total likes in real time, and records the click count.
- At the same time, the app should start a timer to check whether the number of clicks increases every second. If it stops increasing, the app stops the timer and report the number of clicks to the business server.
- If the continuous clicks last longer than 3 seconds, report the clicks every 3 seconds. Clear the recorded clicks to zero after each report.
- When the business server receives the reported click number, it should update the total number of likes. Then it calls the Send a Custom Message interface of ZEGOCLOUD Video Call to notify all members of the room.
- When room members receive the update via onIMRecvCustomCommand, they should check if they are the clicker. If not, they update the total clicks and play the like animation.
- When room members play the like animation, all animations can play if there are fewer than 5 likes. If there are more than 5 likes, only 5 animations should play.
How to Structure Like Data?
It is recommended that the app report the like data in the following format:
{
"userID": "123123",
"count": "12",
"timestamp": "1707123211"
}
The business server notification of likes is recommended to be sent in the following format.
{
"notifyType":20001,
data:{
"total": 10023,
"likes": [
{
"userID": "123123",
"count": "12",
"timestamp": "1707123211"
},
{
"userID": "456456",
"count": "2",
"timestamp": "1707123310"
},
...
],
}
}
Conclusion
Sending likes is a simple yet powerful way for viewers to show appreciation to hosts during live-streaming events. It creates a positive, interactive atmosphere and motivates hosts to deliver even better content. However, the volume of likes can place a strain on the business server, especially as the audience grows.
To address this challenge, developers can leverage ZEGOCLOUD’s comprehensive Video Call solution, which includes an SDK and server API. By continuously collecting like data and reporting it periodically to the ZEGOCLOUD server, the business server’s load is reduced. ZEGOCLOUD’s server processes the data efficiently, sending it in batches to all users. This ensures smooth performance and a seamless experience.
With this solution, developers can optimize server load while maintaining a seamless, engaging live-streaming environment for both hosts and viewers. Sign up today to get a 10,000 minute free trial.
Let’s Build APP Together
Start building with real-time video, voice & chat SDK for apps today!