HTTP/PHP Server for Java Online Game, Bad Idea?

I’m relatively new to Java and I’m planning my next project, it will be a slow-paced command-based online game. I’m hesitant to make the game’s server in Java due to inexperience, and instead writing PHP scripts on an HTTP server (something I have experience with). The client will be in Java. Is the HTTP server a bad idea? Should I just bite the bullet and learn to code a server in Java?

HTTP server is actually quite fine. However, coding a server in Java is more exciting :slight_smile:

If you want to make this as fast as possible, use HTTP. Otherwise, I suggest learning how to create Sockets and whatnot since it might be useful later on :slight_smile:

HTTP might be a very good idea since it often leads to a very scalable architecture (if you stick to its stateless nature). You might want to look at http://jersey.java.net/ for a nice high level client for webservices. Serverwise you could use jersey too… Using webservices allows you to switch later to javascript/GWT easily. BTW many Zynga games use PHP on the serverside.

Hi Aeroc,

The first version of State of Profit used php as server side. Eventually I had the need to switch to a full blown java socket app though seeing as I really wanted to way initiated communication. If you want the server to send things to the client without the client having to poll for changes constantly you’re better off with a java server. If you are fine with only sending commands/polling for updates then go ahead with php so you can focus on the game instead of the server. Try to keep the communication separate from the game logic though so you can switch it out at a later stage if needed.

Mike

it will be a slow-paced command-based online game

I know games from the past (and I believe it is still used sometimes) that used EMAIL as its possible communication protocol. I’d say that HTTP is fine for this kind of game, especially if you combine it with for example JSON as your message format. Google has created a nice little API called GSON to make that very easy indeed.

when you mean slow do you mean like turnbased?

Thanks for everyone’s advice. =)

Yep.

in that case yeah, I think that you should probably be fine. although you should think about how the other players will know it is their turn? will they just poll every couple of seconds to check?