0
\$\begingroup\$

I'm making a MMO Bullet Hell game on Game Maker Studio 2 with a node.js server and I'm already able to receive and send information through UDP connections. I NEED to keep the server as fast as possible on the response to avoid lag to players since on this genre lag means death in most of the cases.

My main problem is: I need to get the ping/ms of the clients on the server and other informations (such as player data) from the client to the server. I'm currently dividing the two, so i send a "ping/pong" packet from the server to the client to get the ping/ms and every time something inside the player data is modified on the client it sends the information to the server on a JSON.

Now to the question: Should I put all the data on a big JSON and send to the server constantly or should i keep my current model and send a packet to get the ms and other packets to send and receive data? Keep in mind that when my player is moving it'll send a bunch of data packets to the server whilst the ping function is running.

\$\endgroup\$
2
  • 1
    \$\begingroup\$ If you're trying to make it as fast as possible, why are you using JSON? \$\endgroup\$ Commented Dec 21, 2020 at 18:02
  • \$\begingroup\$ @user253751 I need to send a big structured pack of data from server to client. Both game maker and node.js can interpret the JSON stringified code and i didn't know a better way to do it and make the code usable do you have any suggestions? The JSON looks a bit like this player = { _x: 0, _y:0, stats: { hp: 100 } } \$\endgroup\$
    – Otarom
    Commented Dec 21, 2020 at 18:06

2 Answers 2

1
\$\begingroup\$

What you really need to do here is bit packing and unpacking. Here is a decent tutorial so you can get the most out of each packet, as each bit you send should convey as much information as possible. JSON might be easy to read, but we are programmers and do not need to actually read the data in our packets (unless debugging!). We simply need to interpret the bits into a usable struct in whichever language we choose.

JSON might be the simplest solution, but it is quite far from the best. The best MMOS spend years optimizing this process. In fact, for MMOs, it may be preferable to use TCP! Here is an excerpt from the link mentioned,

UDP is another widely used transport protocol, but it cannot be applied to MMORPGs directly due to the lack of reliable and in-order transmission. To deal with packet loss and the reordering of game messages that need strict reliability and in-order processing, an excessive amount of effort is required if UDP is adopted.

Another thing you need to think about is encryption. Sending plaintext packets in JSON is a quick way to introduce vulnerabilities to your game. Packet editors are one of the oldest tools hackers have in their toolbox, and plaintext packets are just asking to be exploited.

Here are a few more resources to explore

http://ithare.com/udp-for-games-security-encryption-and-ddos-protection/

https://pvigier.github.io/2019/09/08/beginner-guide-game-networking.html

https://gamedevcoder.wordpress.com/2011/08/28/packet-encryption-in-multiplayer-games-part-1/

\$\endgroup\$
0
\$\begingroup\$

While everybody is super experienced with telling that JSON is literally not the option along with the UDP, in your case it is better to send chunks of data, because even though it theoretically will use more traffic, it will result in more fail-safe environment as if you lose one packet with some data, it will be some what all right because you will get it anyway later, while getting other packets successfully, but if you will lose big data, it will hurt more, as you've lost a lot, creating nearly an artificial disconnection, so it will be much of a severe problem.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .