Jump to content

Securely handling movement/game logic server-side


Oyed
 Share

Recommended Posts

This is something I've been thinking about for a while and I was wondering if anyone could help, or had some input.

 

All of the Canvas multiplayer Socket.IO/Websocket tutorials I've seen on the web, including BrowserQuest, handle game logic locally and then send it to the server to broadcast to connected parties. This allows people, with little knowledge of JavaScript, to cheat really easily.

 

My question is; what is the best way to overcome this? I've tried a couple things before, for example sending key presses to the server and handling logic, then broadcasting to connected parties, but it can easily lag behind with a few people online.

Link to comment
Share on other sites

Send the players positions, x, y (and z, if it's a 3d game) to nodejs. Process that request inside node, check for the distance to prevent a player from teleporting all around the map, then pipe that data to all other players in the game to notify where the player went.

 

It won't lag, unless maybe you have someone that lives half a world away, but in that case, create a server in that location and direct those players to that server. Think of Diablo 2 (UsWest, UsEast, Asia, Europe) and use Redis for pub sub.

 

If you're working with node, I highly recommend Pub Sub with Redis (http://goldfirestudios.com/blog/136/Horizontally-Scaling-Node.js-and-WebSockets-with-Redis) as if you want a massive mmorpg game, you will need to utilize more than one nodejs v8 isolate (1 core). And use a front end proxy like nginx or haproxy

Link to comment
Share on other sites

Send the players positions, x, y (and z, if it's a 3d game) to nodejs. Process that request inside node, check for the distance to prevent a player from teleporting all around the map, then pipe that data to all other players in the game to notify where the player went.

 

It won't lag, unless maybe you have someone that lives half a world away, but in that case, create a server in that location and direct those players to that server. Think of Diablo 2 (UsWest, UsEast, Asia, Europe) and use Redis for pub sub.

 

So continue to process game logic client-side, but have checks in place server-side?

Link to comment
Share on other sites

So continue to process game logic client-side, but have checks in place server-side?

 

Yeah, if you using a point to click method (like diablo 2) once that player clicks move that player on the client instantly so there is no 'lag', but secretly send the x,y positions to the server to then notify all other players.  That's the beauty with websockets. And those other players will be notified almost instantaneously.

Link to comment
Share on other sites

Yeah, if you using a point to click method (like diablo 2) once that player clicks move that player on the client instantly so there is no lag, but secretly send the x,y positions over to notify all other players.  That's the beauty with websockets.

 

It's a top-down game, however movement isn't point-to-click, nor is it restrained to a grid, it's free Left-Right-Up-Down movement

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...