GitHub Documentation

Async authoritative turn-based multiplayer in scope for Colyseus?



  • Hello,

    I am new here:
    Is Colyseus a good fit for a game where player1 can just start their turn and go offline, then another player can decide to pick up that game and play with player1 and go offline again. The turns could be fairly big (few MB maybe).

    From what I have read it seems Colyseus is geared more towards real-time and games where people start at the same time, but it also says it would be very flexible. My fear is that Colyseus could hard to work with and that it would not scale well for this type of game. Am I right?

    So would something like this be easy to implement in Colyseus, and what would the best practice be?



  • I really like Colyseus and use it for my games with synchronous gameplay. For the game you described, with asynchronous gameplay, I personally would not use Colyseus.

    Small definition of terms to avoid misunderstandings:
    "synchronous gameplay" means players who are online and playing see each other and can interact with each other instantly.
    "asynchronous gameplay" means players go online and play independently from each other, comparable with physical board games with a turn order for players.

    If I would make a game which has asychronous gameplay and which has a game client (frontend) and game server (backend) being implemented in JavaScript or TypeScript and the game server is running on node.js...

    ...I would make the game server a simple HTTP server receiving requests over HTTP POST including "stringified" JSON objects and again sending back "stringified" JSON objects as HTTP responses. As hillarious as it might sound I would start with the "hello world" example on the website of node.js (see here) and start building the game server from there (actually I already did exactly that myself). The game client would simply do HTTP POST requests to the server, with all data required for the game, for example authentication or gameplay inputs, in the POST-part of the request, nicely wrapped as JSON object. The game server would process those requests and send the game state back, again as JSON object. Especially at the beginning of a JavaScript/TypeScript project using JSON is great because it is so simple. Later, if the game gets bigger, either because of growing amount of data or growing amount of players, the JSON could be swapped against something else, for example BSON or MsgPack.

    In this scenario any "event" is initiated by the game client and the game server only reacts to those. If this scenario must be extended because the game server wants to initiate an event, for example because one player wants to send a chat message to the another player who might currently be registered as "online", the simplest way would be to use long polling. A friend of mine currently makes an asynchronous game just like that and it is working really good, probably because of the simplicity of the used network technology.

    Maybe an asynchronous game can even be made with Colyseus, but from what I know about Colyseus it is not a good fit.



  • Hey, thanks for your answer! After two weeks I just thought this community is not really helpful and looked elsewhere.

    There is a lot of really useful information in your post. I will really take it to heart. I have come to a similar conclusion, will probably use my own REST server or a parse-server. Colyseus is not really useful for this kind of server, but they don't tell you that ;-)

    Thanks again!


 

© 2021 Lucid Sight, Inc