Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'm working on a Networked multiplayer game, but while developing and for testing I want to set up a local server that acts like the multiplayer server.

My thought is to approach the server as a proxy setup. Creating a class that the client sees and essentially allowing it to either load the server code in itself or to use a networking layer.

Is this a good approach? Are there other approaches to look into? What pitfalls should I be watching for?

Update

A bit more specifically I need to do this because I am targeting the Ouya and I can't guarantee a network connection, or even a spare machine to run the server on. And inside Android it is more difficult to setup and launch a service rather than include my server code right into a client build.

share|improve this question
add comment

1 Answer

In my experience, I would suggest you start with a networking layer, right out of the gate. Connecting to a network (and the issues related to it) are worth confronting head on. Since it's a multiplayer game, you're going to want to start facing those issues early (and often).

Further, my recommendation would be to develop your server code, run it locally, and when you're ready, move it to its real location. In other words, rather than think of the server as merely a temporary solution for testing, think of it as the ultimate solution in a temporary location, otherwise you're going to be developing the server code twice.1 If you're running your server on the same computer as your emulator, you can just connect to localhost. Even better is to connect to your IP address (the external one, seen from outside your network), and then set up port forwarding of whatever ports your game communicates over to send the packets to your server computer. With that setup you can still test with a reasonable number of people without raising the ire of your ISP.

As far as where the codebase "lives," my suggestion would be: do NOT include the server code in your client codebase. Advantages include:

  • It keeps the client smaller. (Which is good, since users don't like bigger downloads)

  • It keeps the server code away from those who would decompile the client to hack your game.

Nonetheless, there will likely be a need for some classes to be shared between the client and server. That's why I recommend that you DO include the client code in your server codebase. Classes that are common to both the client and server can live on the client side. (Alternatively, you could have three codebases: (1) server; (2) client; and (3) shared, but I don't think that's necessary, since the server having extra code it doesn't need from the client isn't a big deal.)

1For my project, I used KryoNet and can't recommend it enough. It's a very simple, clean, open source client-server solution, written in java.

share|improve this answer
    
I'm actually already setup quite like you suggest. 3 Code bases, networking already works. My problem is I'm targeting the Ouya and I can't guarantee a network connection while I'm developing, and it's much more difficult to try to start the server as a secondary Android application. –  Chris Mar 3 '13 at 1:41
    
How about running the server on the computer that you're developing on? Awesome that you're targeting Ouya, by the way. –  Cameron Fredman Mar 3 '13 at 1:47
    
I develop in several places, one of them being the college. And there especially I can't control the network. Also, I'd like to be able to demo the game with less hardware and hopefully less chances of something going wrong. I've been working on this the past few hours and will be testing later tonight or tomorrow. so far, it's literally an interface and a class and it looks like it should do what I need. –  Chris Mar 3 '13 at 1:51
    
Additionally, I haven't been able to connect my dev kit to any unsecured wireless networks. The kind you'd find at a lot of hotels / conference centers / colleges, that require you to connect to the web and fill out information. –  Chris Mar 3 '13 at 1:52
    
Sounds like you've worked out something that suits your development needs. –  Cameron Fredman Mar 3 '13 at 2:51
add comment

Your Answer

 
discard

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.