Colyseus

Multiplayer Game Server for Node.js

Focus on the gameplay instead of networking.

If you're a solo indie developer, small or large game studio, Colyseus will allow you to deliver realtime or turn-based multiplayer games in record time.

Supported platforms

Colyseus comes with official support for these platforms.

Need a client for a different platform? Share your interest on the discussion board!

Example

Have a glance on the usage of the framework.
See more examples.

Server-side

              import { Room } from "colyseus";
import { Schema, MapSchema, type } from "@colyseus/schema";

class Player extends Schema {
  @type("number") x: number;
  @type("number") y: number;
}

class State extends Schema {
  @type("string") currentTurn: string;
  @type({ map: Player }) players = new MapSchema();
}

class GameRoom extends Room {
  onCreate () {
      this.setState(new State());
  }
  onJoin (client) {
      this.state.players[client.sessionId] = new Player();
  }
  onLeave (client) {
      delete this.state.players[client.sessionId];
  }
  onMessage (client, data) {
      // handle player messages
  }
}

Client-side

              const client = new Colyseus.Client("ws://localhost:2657");

try {
  const room = await client.joinOrCreate<State>("game");
  console.log("joined successfully", room.sessionId);

  room.state.players.onAdd = function(player, i) {
    console.log("player joined!", player);
  }

  room.state.players.onRemove = function(player, i) {
    console.log("player left!", player);
  }

  room.state.players.onChange = function(player, i) {
    console.log("player has been updated!", player);
  }

  room.onStateChange((state) => {
    console.log(`${ room.sessionId } has a new state:`, state);
  })

  room.send("Hello world!");

} catch(e) {
  console.error("couldn't join room:", e);
}

Features

Authoritative server. Designed to be intuitive and simple to use.

Showcase

A selection of games powered by Colyseus, made by the community.

Work for hire

Hi, I'm Endel. I'm working as a full-time freelancer since 2018.

@endel

Get in touch!