Prepare for
the fight!

Shepherd Of The Night Game project. Multiplayer is available!

Hi everyone! After 3 months of intensive studying of Socket.IO the multiplayer finally works!

It did not take a lot of efforts and encountering of big problems. Socket.IO appeared to be quite easy to use and implement. Of course, it is only considered the user API. I absolutely do not know how it works on the lower level and probably for now it is not important.

So what do we have now:

Server works on Google Cloud Platform and accessible throughout the Internet. Users connect, game starts, units move, abilities works, all the game mechanics operates quite well. But sometimes server starting to behave incorrectly (users spontaneously disconnect or can’t connect or do not see each other after connection). I suspect it happens because Google server works not as fast as I need, and thus do not processes requests in proper order.  Apparently, it’s because I have free billing plan which is very limited in its performance. To mitigate this problem there is a server restart button on the Enter Your Name screen and it is highly recommended to reset server if you start a new game.

For not exceeding the free limit of traffic and processor time per month, I decided not to send to the server all coordinates of every unit every timeframe. I send to the server only mouse clicks users made. Server receives them and sends them back to all participants. Client soft considers this clicks as made by a real person and performs the proper action. So all computation is made on the client side.

It helped to reduce the amount of traffic greatly, because all that is being transferred are just click coordinates and names of the users.

On the other side, because of ping, it brings situations when events happening on the screen of one player are a little bit different what other players see at the same time. For example one player has already killed a monster, and went to another point, but on his friend’s screen he is still fighting.

On my opinion, for academic purpose it is not a big deal. Clients send requests to server, server responds, units move and kill each other – what else can we expect? I think multiplayer topic is finished well.

So now let’s not linger and dive into the next topic – React and Angular JS.