I'm developing a real-time chat application for a company that includes features like messaging, calling, video calls, and a collaborative canvas. While I've successfully implemented most of the functionalities, I'm stuck on how to handle the 'seen' feature and the call logs. Specifically, I need to send a message in the chat whenever a call is ended, indicating the call duration or if it was missed. Should I set up a hook to listen for state changes and send a message, or is it better to emit a signal at the end of the call to broadcast this information? I would appreciate insights from experienced developers on the best and most common approaches for implementing this.
2 Answers
For a case like this, you might want to consider using Centrifugo for real-time communication. It's solid for handling message broadcasts and events, although I haven’t implemented it myself yet. But it seems to fit well with your use case!
Great suggestion! I'll definitely check it out.
It's important to separate your messaging logic from the UI components. Start by creating a service that handles sending and receiving messages and manages connections internally. This way, your chat app remains agnostic of the underlying connection details. Define all update types you’ll handle, set up their corresponding handlers, and sync the state with your renderer, which I assume is React. Decoupling your logic will make it a lot easier to maintain and test later on. You might also consider using a web component for your chat/video interface to keep things tidy!
I was feeling lost trying to integrate everything at once, but your advice about restructuring really helped clarify my approach. Thanks!

Thanks for the tip! I hadn’t come across Centrifugo before, but it looks really promising.