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 planning to create a simple math multiplayer game and I plan to just use Ajax for the server/client communication but I'm not sure if this is sufficient or if I need a socket server.

The game will look like this:

  • 2-4 users
  • all get a simple math task (like: "37 + 14")
  • they have to solve it as fast as possible
  • first user who solves it is the winner

I will track the time for each user, since the game started, on the client side and everytime a user gives an answer, the answer and the passed time will be send to the server. Additionally I'll add a function which will check every 3 seconds if the other users finished, how much time they needed and who won.

Do you think this is possible just using Ajax? What alternatives are there?

share|improve this question
3  
It definitely is possible. From a design standpoint, I strongly recommend that you consider letting the server keep track of the time to prevent users from altering this on their end -- your users are going to have to login and identify themselves anyway, right? So you'll presumably use a cookie to differentiate them. –  Randolf Richardson Jun 19 '11 at 15:37
    
For the first version I will keep it pretty simple, no cheat prevention etc. Just wanted to know if it is sufficient for a very first version (just want to see if it works and users like it). –  Christian Strang Jun 19 '11 at 16:05
1  
I wouldn't use the XML formatting part of AJAX, as it really isn't needed. –  Jonathan Connell Jun 19 '11 at 16:17
    
@3nixios: Yup! Parsing plain/text is quite easy anyway, especially when you're the one deciding what data gets transferred. –  Randolf Richardson Jun 19 '11 at 23:29

2 Answers 2

up vote 1 down vote accepted

I think that Ajax is easily sufficient for this task.

The alternatives I can think of are:

share|improve this answer
2  
Another great alternative is Java (specifically, a Java Applet). –  Randolf Richardson Jun 19 '11 at 15:32
4  
It would be a great alternative if we were in 1995. –  Raynos Jun 19 '11 at 18:12
1  
@Raynos: Thank you for pointing out that Java has such a long history -- the technologies that have stayed around have done so because they work well. I would say that for both Java and Flash, which each have significantly long histories, that they've both improved greatly over time; originally as web browser plug-ins these tools had their challenges (including performance problems), but now here we are ~16 years later with high-performance computing and technologies that grown to be much more versatile, smarter, and faster. –  Randolf Richardson Jun 19 '11 at 23:38
1  
@RandolfRichardson Could you show me a polished modern Java Applet which was designed to be used as an applet and not ported? (Recent popular Java Applets like minecraft were just ported as an applet because it was "free"). From the tools I've seen, applications written as Java Applets lacked a modern/polished look. –  Raynos Jun 20 '11 at 5:50
    
I can't argue they're alternatives. But so is C++. C++0x is coming out soon too. Probably more versatile, smarter and faster. Probably no more helpful in this context as well. –  Rushyo Jun 22 '11 at 12:33

Do you think this is possible just using Ajax? What alternatives are there?

Yes for the communication ajax is a valid channel to use.

But if by AJAX you mean sending single ajax requests using something like jQuery then no it's not a valid choice, merely because there are better options.

I highly recommend you use either

  • WebSockets and a range of fall-back techniques for older browsers
  • or COMET techniques.

For WebSockets I recommend you use an abstraction layer like socket.io (for node.js) or APE (for PHP).

Both of those use feature detection to use the best communication channel possible. This will pick WebSockets, COMET or a flash websocket bridge and those technologies support a wide range of browsers whilst still emulating a proper socket connection for you.

Arguably you can also use a SilverLight or Java websocket bridge but those are less common and not as well supported.

As for COMET the techniques are too highly integrated into the server-side stack/language to give generic advice.

If you need technology that interfaces well with a particular server side stack feel free to ask.

share|improve this answer
    
I thought about this but my managed server doesn't support sockets. Is it possible to rent a virtual server for around 10 Dollar/month or do I need a full server (I have no experience with sockets at all)? –  Christian Strang Jun 21 '11 at 8:27
1  
@ChristianStrang that's interesting, You can use an external service like pusher. Are you sure you can't just install node.js or APE on your managed server? –  Raynos Jun 21 '11 at 8:52

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.