Search code examples
htmlnetwork-programmingwebsocketreal-timebandwidth

Does continous streaming of positions work for a HTML5 action-intensive server-client game?


In an action intensive (fighting-style) game designed for ~100 players, is it sufficient to stream the positions of every player to every player via websocket, considering current bandwidth limitations, or would it be overkill? If so, are there options that would not?


Solution

  • You can do the math: given N players, an update rate of M events/s, and K bytes payload per events you would need at least N x N x M x K bytes/s server bandwidth.

    Whether that naive approache is acceptable and works depends on N, M and K, as well as the network conditions.

    I'd suggest thinking over that approach: does every player need the positions of all others players or only of those that are "near" (visible) to the respective player.

    Regarding WebSocket: go with that, it's the right technology if you want to do browser based games.

    Emerging P2P protocols like WebRTC usually don't work with games like that, since the server is no longer in control of the positions (clients can "fake" their stuff).