3

I'm getting started with creating the back-end architecture to support a turn-based mobile game. Most of my research tells me that a stateless web server should work just fine, because the client is not always connected to the server.

My question is, how would I write the logic for GET requests. If I need a user to be updated when his or her opponent has made a move...do I keep doing GET requests every few seconds? Isn't it a big problem that the server is one-directional, as in the server can't notify the user when it is his/her move? Or am I overestimating it, and doing a GET requests every other second is perfectly fine?

Thanks!

4

1 回答 1

1

我认为你应该考虑使用 WebSockets:

http://en.wikipedia.org/wiki/WebSocket

即使您不使用浏览器,也可以使用 iOS 打开到使用端口 80 的套接字的连接(您不需要任何额外的规则)。WenSockets 为服务器提供了一种标准化的方式来向浏览器发送内容而无需客户端请求,并允许在保持连接打开的同时来回传递消息。

于 2012-12-05T09:33:19.287 回答