In my previous projects, network communication was implemented based on HTTP. However, for games where multiple gamers compete simultaneously, HTTP short connections do not support server push. In this way, the client cannot receive messages from the server.
The simplest method is to initiate a request to the server at a scheduled time. Obviously, efficiency and traffic are problems.There is also the comet method, that is, the server maintains a connection and returns only when data is available.
I searched for comet on the Internet and commented that this method is not very efficient.
After HTML5 supports websocket, it seems that socket connection is an efficient and simple method. The client uses Socket. io is relatively simple. The server needs to find an engine, which is easy to use. It is best to use a familiar node. JS, such as Erlang, although the introduction on the Internet is very powerful and easy to use, it is too inefficient to learn a new functional language.
Node. js bare socket Writing seems to be very troublesome, and the writing quality is certainly not good, so Netease's pomelo has become my choice. After reading the pomelo tutorial, the design of this item seems awesome, and it seems very simple to use. Some commercial programs are also in use. It should be more reliable.
Appendix:
In-depth introduction to node. js game server development 1-Introduction to the basic architecture and framework
It mainly promotes pomelo.