HTTP as a communication layer for the game

I just started developing games and wanted to create a simple multiplayer game. Is it possible to use HTTP as the main communication protocol for a multiplayer game. My game will not make a few requests per second, but rather a request every few seconds. The client will be a mobile device.

The reason I'm asking is, I thought it might be interesting to try using Tornado, which reportedly scales well and supports non-blocking requests and can handle "thousands of concurrent users".

This way my client can make an HTTP request and when the game server has something to say, it will respond to the request. I believe this illustrates what some people call the COMET design pattern.

I understand that working at the socket level has less overhead, but I'm just wondering if this is even possible given my game requirements? Or am I just thinking crazy?

Thanks in advance.

+2


source to share


5 answers


Q: Is it possible to use HTTP as the main communication protocol for multiplayer games.

and. Using HTTP as the communication protocol might make sense for your game, it might not, but it is for you. I have developed apps for Windows Mobile, Blackberry, Android and iPhone for over 10 years. All the way back to CE 1.0. With that in mind, here's my opinion.

I suggest reading RFC 3205 first as Teddy suggested. He explains in detail the reasons for my proposals.

In general, HTTP is good because ...

  • If you are developing a browser game - flash or javascript where you are not building a client then use HTTP because it is built anyway, and probably anything you can use.
  • You can get HTTP server hosting with decent scripts super cheap somewhere
  • There are many tools and a lot of documentation available.
  • Easy to get started


HTTP can be bad because ...

  • HTTP introduces a huge overhead in terms of bandwidth when compared to a simple TCP service. For example, Omegle.com sends 420 bytes of header data to send a 9 byte payload.
  • If you really want a comet / long poll, you'll spend a lot of time figuring out how to get your server to speak correctly, rather than working on what it says.
  • The constant flow of http traffic can overwhelm mobile devices in both processing and bandwidth, giving you less resources to focus on your gaming performance.
  • You might not feel like you know how to create your own TCP server, but it's really easy.

If you are writing server AND client, I would go straight to TCP. If you already know python, use the twisted networking library. You can get a simple server in an hour or so just by following the instructions.

Check out the LineReceiver example for a super simple server that you can test with any telnet client. http://twistedmatrix.com/projects/core/documentation/howto/servers.html

+3


source


WRT:

"my client can make an HTTP request, and when the game server has something to say, it will respond to the request.



This is not how HTTP is supposed to work. So, no, HTTP won't be a good choice here. An HTTP timeout request if no response is received back with a timeout (60 seconds is the usual default, but this will be specific).

+1


source


Please read RFC 3205: About Using HTTP as a Substrate which deals with this.

+1


source


With the target platform being mobile (and the limited bandwidth that entails), HTTP won't be the first tool I pulled out of the box.

0


source


If you just enjoy playing with all this technology, then you can take pleasure in it. Tornado seems like a smart choice if the example on the website is something to be done. But any simple server-side web language would be sufficient to serve the answers you need at the rate you specify. The performance specs are likely to be irrelevant here.

The COMET method is when you leave an HTTP connection open for a long period of time. This is primarily for "server push" of data. But usually you don't need this. It is usually much easier to do retry requests and handle responses individually.

0


source







All Articles