Web Monitoring Panel for Colyseus (v0.9.5+)
This library is experimental. Use at your own risk.
Consider backing Colyseus development and its support on Patreon.
import * as express from "express";
import * as cors from "cors";
import { Server } from "colyseus";
import { monitor } from "@colyseus/monitor";
const app = express();
// Cross-Origin Resource Sharing is necessary if you use a different IP
// addresses for client and server.
app.use(cors());
const server = http.createServer(app);
const gameServer = new Server({ server });
// Register your room handlers.
gameServer.register("chat", ChatRoom);
// Register monitor route AFTER registering your room handlers
app.use("/colyseus", monitor(gameServer));
gameServer.listen(port);
You can use an express middleware to enable authentication on the monitor route, such as express-basic-middleware
:
import * as basicAuth from "express-basic-auth";
const basicAuthMiddleware = basicAuth({
// list of users and passwords
users: {
"admin": "admin",
},
// sends WWW-Authenticate header, which will prompt the user to fill
// credentials in
challenge: true
});
app.use("/colyseus", basicAuthMiddleware, monitor(gameServer));
Install the dependencies and start the dev-server:
npm install
npm start
Access the UI on http://localhost:2567/colyseus.
MIT