How to use @colyseus/monitor - 5 common examples

To help you get started, we’ve selected a few @colyseus/monitor examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cyclegtx / colyseus-iog-state-sync / index.ts View on Github external
// Attach WebSocket Server on HTTP Server.
const gameServer = new Server({
  server: createServer(app)
});

gameServer.register("ExampleRoom", ExampleRoom);

gameServer.register("ExampleBodiesRoom", ExampleBodiesRoom);
gameServer.register("BattleGroundRoom", BattleGroundRoom);

app.use('/', express.static(path.join(__dirname, "static")));
app.use('/', serveIndex(path.join(__dirname, "static"), {'icons': true}))

// (optional) attach web monitoring panel
app.use('/colyseus', monitor(gameServer));

gameServer.onShutdown(function(){
  console.log(`game server is going down.`);
});

gameServer.listen(port);
console.log(`Listening on http://localhost:${ port }`);
github damian-pastorini / reldens / src / server / index.js View on Github external
app.use(cors());
app.use(express.json());
const port = Number(config.app.port);
const server = http.createServer(app);
// game server:
const gameServer = new Colyseus.Server({
    server: server,
    express: app
});
// main room:
gameServer.define(share.ROOM_GAME, RoomGame);
// game monitor:
if(config.app.colyseusMonitor){
    const monitor = require('@colyseus/monitor');
    // (optional) attach web monitoring panel:
    app.use('/colyseus', monitor.monitor(gameServer));
    console.log('NOTIFICATION - Attached Colyseus Monitor.');
}
// server shutdown:
gameServer.onShutdown(function(){
    console.log('NOTIFICATION - Game Server is going down.');
});
// @TODO: optimize the query.
// loading scenes data:
let queryString = `SELECT 
    s.*, 
    CONCAT('[', 
        GROUP_CONCAT(
            DISTINCT 
                '{"i":"', sc.tile_index, 
                '", "n":', (SELECT CONCAT('"', name, '"') FROM scenes WHERE id = sc.next_scene_id),
                 '}' 
github halftheopposite / tosios / packages / server / src / index.ts View on Github external
app.use(express.json());

// Game server
const server = new Server({
  server: createServer(app),
  express: app,
});

// Game Rooms
server.define(Constants.ROOM_NAME, GameRoom);

// Serve static resources from the "public" folder
app.use(express.static(join(__dirname, 'public')));

// If you don't want people accessing your server stats, comment this line.
app.use('/colyseus', monitor(server));

// Serve the frontend client
app.get('*', (req: any, res: any) => {
  res.sendFile(join(__dirname, 'public', 'index.html'));
});

server.onShutdown(() => {
  console.log(`Shutting down...`);
});

server.listen(PORT);
console.log(`Listening on ws://localhost:${PORT}`);

@colyseus/monitor

Web Monitoring Panel for Colyseus

MIT
Latest version published 18 days ago

Package Health Score

86 / 100
Full package analysis

Popular @colyseus/monitor functions