How do you make an optimized and dynamic networking server/client in an MMO-type game?

Viewed 56

I've been dabbling a bit with networking on a server/client(s) based format and I've started implementing some game mechanics in my project. Everything works fine and as expected but adding any kind of networked element means adding a whole lot of code for a very simple mechanic.

For example, just for a simple auth without encryption or anything else, I need a CanAuth instruction from the client, which is then either accepted or declined from the server depending on current state, then if server accepts I need to have an actual auth from client to server which will give auth info, then server has to process and answer client to say that auth is denied or accepted.

All of these are very basic instructions, but the way I do it (Which is probably the problem) is that for each instruction I need about 4 classes:

  • CanAuth on client, to send to server
  • CanAuth on server, to receive and interpret from the client
  • CanAuthAnswer on server, to send to client after processing CanAuth request
  • CanAuthAnswer on client, to receive and interpret from the server

On top of that, I also need to check which type of instruction is received from the server on the client, and do the same thing on the server from the client, which means I need to have a large enum with all Instruction Types, and when I receive a message from either client or server, I need to check which enum type it is and then use the right instruction on each class to start the processing part.

Basically, adding a very simple instruction to my game can take about 30 minutes. A game mechanic can have something from 3 to like 50 instructions, depending on how complexe the mechanic is.

How would I go about and optimize, make everything dynamic, so that I don't have to spend most of my day just making instructions on both client and server ? I'm sure there's a better way to handle this, and I just don't see it.

Thanks in advance for answers, and sorry for my bad english.

0 Answers
Related