How do I make a Relay-Server with Node.js & Websocket

Get help using Construct 2

Post » Thu Jun 23, 2016 2:17 pm

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. :D 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:
  1. 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.
    Image
  2. The Relay-Server should have the ability to broadcast messages to all Clients
    Image

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
B
11
S
4
G
5
Posts: 74
Reputation: 3,435

Post » Tue Jun 28, 2016 7:38 am

*bump*
B
11
S
4
G
5
Posts: 74
Reputation: 3,435

Post » Tue Jun 28, 2016 12:16 pm

Hello,

Sorry I can't help you for now but I will attempt something similar in a near future, maybe at some point we can trade tips. :) I just wondered what is the use of the relay server? Can't the host communicate with the clients directly?

Thanks
B
4
S
1
Posts: 4
Reputation: 308

Post » Tue Jun 28, 2016 12:24 pm

Thanks, that would be awesome.

In my Project, I made 2 games, one for the server and one for the client. The host is doing the whole work, the client is only sending requests and the host sends results back. I made this to prevent cheating. The Relay server just communicating with the host and all players.

EDIT: I already made this with the official multiplayer plugin, but i don't want to rely on a signaling server.
B
11
S
4
G
5
Posts: 74
Reputation: 3,435

Post » Tue Jun 28, 2016 9:03 pm

Ok. So the game that is running on the host is used to process gamestate and logic and to validate that the clients don't do illegal moves? From what I understand the game on the host is not played by an actual person, it is only a resident app.

When I get the right to send PMs I will send you one with my solution thus far. I don't use a relay server, but it might give you ideas.
B
4
S
1
Posts: 4
Reputation: 308

Post » Tue Jun 28, 2016 9:23 pm

This is exectly how it should work ;)

That would be realy awesome :D Thanks
B
11
S
4
G
5
Posts: 74
Reputation: 3,435


Return to How do I....?

Who is online

Users browsing this forum: dop2000 and 9 guests