Skip to content

rivet-gg/plugin-colyseus-server

Repository files navigation

🔩 Rivet Colyseus Plugin

Plugin to Colyseus for easy development with Rivet.

Example

See a more detailed example here.

import { listen } from "../src/index";

export default listen({
	async initializeGameServer(gameServer) {
		gameServer.define("chat", ChatRoom).enableRealtimeListing();
	},
});

Running Test Server

The test server is used for manual testing for development. For more comprehensive examples, check out the Colyseus examples repo.

Project setup

  1. Create a game on the Rivet Developer Dashboard
  2. Install the Rivet CLI
  3. Run rivet init --recommend to link your game

Running

  1. Run the server in one terminal: yarn run test-server
  2. Copy the token from the line that starts with "[Rivet] Token:"
  3. Run the test client here

FAQ

What happened to initializeExpress?

Rivet game servers run only game code and nothing else. We support deploying static content with Rivet CDN.

If you need to run a custom API server, take a look at Fly.io or Railway.

Why not use the existing MatchMakerDriver?

The provided MatchMakerDriver interface by Colyseus is too rigid to use in conjunction with Rivet. Under the hood, Colyseus will use LocalDriver for the matchmaker.

We hope to eventually merge a more flexible matchmaking interface in to Colyseus in order to cleanly interface with the Rivet matchmaker.