Building a Message Queue
Joining a call and sending messages works great. But there’s a problem that you might have already discovered: the way you’ve written the chat feature, it’s possible for users to compose and attempt to send messages outside of a connected state. Go ahead and reload one of your browser windows and, before joining the call, compose and send a message. You’ll see the message appended in the chat box as though everything’s hunky-dory, but the input box will not be cleared and your console will report an error like Uncaught TypeError: can’t access property "send", $peer.chatChannel is undefined.
We need to decide what to do when users compose and send messages outside of a connected call state. While we could do something ...
Get Programming WebRTC now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.