Sending to all connected websocket clients #2795
-
I'd like to be able to broadcast a message to all websocket clients currently connected. I'm thinking this would be something like this
is that... reasonable? I feel like I'm mucking around in undocumented innards here. Any gotchas? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
Please see our documentation, and follow the guidelines in our tutorials. mongoose/tutorials/core/multi-threaded-12m/main.c Lines 69 to 76 in 793171e |
Beta Was this translation helpful? Give feedback.
-
Ah I missed that thank you!! Maybe link that in the "WebSockets" section of the tutorials list, I didn't think to look in the "Timers" section! |
Beta Was this translation helpful? Give feedback.
-
Yeah I was just thinking it could be linked, it's clearly a timer tutorial mainly. For websockets specifically "send to all" is a common thing one might look for within the websocket interface so a breadcrumb "also see this one" link would be handy. (Your system has the ability to "send to all that you've tagged a certain way" which is even better.) Just a mild suggestion, thanks for the excellent code-- probably the most well organized straight-C protocol stack implementation I've ever seen, I have no idea how you managed to make it so elegant when most are so encrusted with pseudoabstractions. Kudos! |
Beta Was this translation helpful? Give feedback.
Please see our documentation, and follow the guidelines in our tutorials.
There are several tutorials doing that.
https://mongoose.ws/documentation/tutorials/core/timers/#websocket-broadcast
mongoose/tutorials/core/multi-threaded-12m/main.c
Lines 69 to 76 in 793171e