I plan to develop browser multiplayer turn-based game (2-6 players per game). Server part planed to write on Java. I have to choose between websockets and AJAX for exchange data in game process. I'm wondering which is the better choice. I thought to use websockets, because it is not critically to support old browsers for me and latest version of browser supports websockets. But I know about websockets problem with proxies and routers. How do you think these problems affect most users? And what is better way to reduce the impact of these problems: use secured websockets instead usual, run websockets server on another (not 80) port? Or it's better to use AJAX? I know about such libraries as socket.io and sockJS. But it's interested about pure websockets.
2 Answers
You should go for secure WebSocket. This will work in almost all network enviroments. Mobile. Enterprise. Etc. The exception potentially being so-called Man-in-the-Middle proxies which can unwrap TLS, and then WebSocket will depend on the proxy supporting and allowing it.
Note that with AJAX alone you don't have a push channel. If you want push and go with Comet, that can have it's own issues with proxies also.
Comments
WebSocket is a persistent bidirectional connection. AJAX is just request-response. For a game, websockets make more sense. WSS should go through proxies, routers should not be a problem for either WS or WSS. However, some proxies are not friendly to persistent connections and could cut it after a while, there is no workaround for that.