Heyho
I could need some help with Javascript. I try to make a Relay-Server with Node.js & Websocket for my game with asynchrone multiplayer. Once i started with this project, i had very little knowledge about javascript and construct but im getting better. I made the same thing with the official multiplayer plugin provided by scirra, and it works reale good for a p2p dedicated server, but I would rather use the websocket plugin for various reasons. Could somebody explain me, how to code a Relay-Server with following functions?
What the Server should do:
- When the Client (right side) sends a message to the Relay-Server, the Server should relay the message to the Host (left side). After the Host processes the message, he should send a replay to this Client. The Client shouldn't send messages directly to other Clients.
- The Relay-Server should have the ability to broadcast messages to all Clients
What i already have done:
- I already installed Node.js and downloaded the Websocket Library
- I read the GitHub page of the Websocket Library
- I watched some tutorials, but i didn't get it yet.
What i need help with:
Im learning reale fast and never had problems to find the right tutorials to improve myself, but im stuck und i need help with how to code these things.
I would reale appreciate, if somebody could teach me.
[EDIT:]
So ... I now know, that I have to set an array on the Relay-Server and assign every user ,who connects, an unique ID to identify them ... the problem is, I don't know how. Would be nice, if the unique ID would be a 4 char ID like the one on the signaling server by scirra.
So something like:
Client sends encrypted Message to Server -> Server adds Unique ID and sends Message to Host
Host sends encrypted Message with Unique ID to Server -> Server removes Unique ID and sends Message to that Client