Multiple Websocket Servers
I was wondering if there was a way to create new websocket servers using the same repl as I was trying to create private rooms and thought that a separate websocket server may solve this. Does anyone know if this would work?
Code here
@19wintersp sorry but I need your help@Coder100 pls help meh
@GatewayDuckYT get on le chat
Please don't ping multiple people. Yeah, tussiez and I had the same problem when we are going to make multiple rooms for multiplayer sortacraft. This would require dynamic rooms and would work best using nodejs or another server-side language. In my mind i have the idea of creating a "fake" url and handling that using the serve functions in golang/nodejs. It will dynamically store session data for multiplayer and be able to handle the information differently based of of what URL of the data being sent. Right now it's a very rough idea and will probably be changed a lot during actual build, but I think I can achieve this through different threads in golang. Otherwise, I just make sure to dynamically add url handlers in nodejs/golang and intercept data and handle it and send it back to the room. It's going to be very hard, though.
This is quite simple: you need to create the illusion. One way of doing this would be to convert from requesting
wss://example.com/
towss://example.com/?room=abcdef
. On the backend, I assume you're handling this by using a list (or object) of connections:You will need to convert that (appropriately, don't copy-paste) to this:
And no, you can't [have multiple WebSocket servers on one repl].
would I do
I already have the code you put above.
And no, you shouldn't
toString
req
. That was my mistake, I've updated my post.