Reputation: 2044
I have read this example from AutobahnPython: https://github.com/tavendo/AutobahnPython/tree/master/examples/websocket/broadcast
It looks pretty easy to understand and practice. But I want to add a little more. Members who submit the correct secret string can send the messages, anyone else can only view the information transmitted. Any idea?
Thanks!
Upvotes: 1
Views: 1341
Reputation: 11
Well it is purely your logic in the code. When you receive the message you are simply broadcasting it, what you have to do is to pass this onto a custom function, and there, do a check:
Create a temporary array that contains list of active authenticated users. when user logs on, it should send this special string, match it, if OK, add this user to this active user list array, if not don't add it. Later, call the bradcast function but rather then taking all online users, use this custom array instead.
That is all that you have to do.
Make sure when someone logs out, remove him from this array.
Upvotes: 1