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

Sneak peak on basic usage. 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 {
  onInit () {
      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");
const room = client.join("game");

room.onJoin.add(() => {
  console.log(`${ room.sessionId } joined!`);
})

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

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.send("Hello world!");

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.
I've successfully delivered 10+ projects since I started.

@endel

Get in touch!