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 * as http from "http";
import { Server, Room } from "colyseus";

// Create HTTP & WebSocket servers
const server = http.createServer();
const gameServer = new Server();

class ChatRoom extends Room {
  // maximum number of clients per active session
  maxClients = 4;

  onInit () {
      this.setState({ messages: [] });
  }
  onJoin (client) {
      this.state.messages.push(`${ client.sessionId } joined.`);
  }
  onMessage (client, data) {
      this.state.messages.push(data);
  }
}

// Register ChatRoom as "chat"
gameServer.register("chat", ChatRoom);
gameServer.listen(2657);

Client-side

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

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

room.onStateChange.add((state) => {
  console.log("new state:", state)
});

// listen for changes on a path on the state
room.listen("messages/:index", (change) => {
  console.log(change.operation); // ~> "add"
  console.log(change.path.index); // ~> "1"
  console.log(change.value); // ~> "Hello world!"
});

room.send("Hello world!");

Features

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

Showcase

A selection of games using Colyseus as Multiplayer Realtime Server