Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm currently working on an online java game. Currently building the messaging system between the client/server and I came across a big if.

I am not experienced as a game programmer, only worked with web applications so far. Currently I made the messaging system using a custom solution and Java NIO with sockets, but it got me wondering: what if it fails? What if I have to change it all to (insert name here)?

So I thought, well, I gonna abstract the network layer of my engine, and if someday I need to change, I'll swap the adapter! But then, came two more problems, how would I abstract a network layer? And of course, is it worth the trouble? Will it be a waste of time?

I'd love some insight on these doubts.

share|improve this question

Sockets are going to be around for a long, long time, so I wouldn't worry about that. If it is already working for you, that's even better!

For an interesting messaging layer, check out ZeroMQ.

In general, if you construct your game to have a general sort of event-based flow (i.e.,"Client 2 fire", "Client 1 die", "Sound explosion (2,3,1)", etc.) and use that for all interactions, you then reduce your problem to routing streams of events and handling them.

Your networking issue then becomes one mainly of serializing these events to a communications channel (for example, over sockets), and then deserializing these events to an event stream on the client/server. If you make that abstraction, then any change to the networking mechanism (sockets to modems to semaphores to whatever) means that you only will have to rewrite that serialization/deserialization/channel management code.

Hope that helps!

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.