I would like to have users create and join a "rooms" so that they can collaborate.
I'm looking at SockJs Multiplexer server and wondering if I can leverage some of that to create and broadcast to specific channel/room.
In the example, a channel is created manually and client connects to that channel.
Would treating these channels as rooms work?
Is there a way to dynamically create these channels instead of manually declaring them on server?
Disclaimer: I didn't notice that you were referring to the Javascript-version of the server until I had written my answer. Therefore, my code examples are given using the Python-based sockjs-tornado, but I guess the principles should be the same.
Yes, you may treat the channels as rooms by keeping a set of referenced connections in each
SockJSConnection
-derived class. To do that, all you would need is to change each connection class slightly fromto
in server.py.
To create the channels dynamically, I changed the
__main__
code andMultiplexConnection
class slightly and added a couple of new classes. In theif __name__ == "__main__":
block,was changed to
While
in MultiplexConnection was changed to
and the classes
were added to multiplex.py.