Skip to content

Latest commit

 

History

History
138 lines (100 loc) · 5.91 KB

0.15_RELEASE_NOTES.md

File metadata and controls

138 lines (100 loc) · 5.91 KB

Colyseus 0.15

For full release notes check out the release announcement.

New features

  • New Room's onBeforePatch lifecycle hook. (#385)
  • Schema: single property callback is now available on all platforms!
  • Possibility to access a client directly through its sessionId (#443)
  • Introduced log flag for incoming and outgoing messages (DEBUG=colyseus:messages) (#465)
  • Support for custom loggers (via logger: Server option) (#442)
  • Introduced support for raw byte message exchange (room.sendBytes() / client.sendBytes(), see example project)
  • Introduced devMode for aiding iterative development process by caching and restoring state and client connections upon server reloading in developement.

Breaking changes

Bug fixes / Improvements

  • "redis" module has been replaced by "ioredis" for cluster support on both RedisPresence and RedisDriver (#452)
  • Fixed an issue where matchmaking filter returning all available rooms when filtering criteria is ""(empty string) or null when using filterBy option. (#342)
  • Some room properties are now fully private (#441)
  • Fixed issue with scaling when using uWebSockets transport (#458)

New Room's onBeforePatch lifecycle hook.

An additional callback has been added for calling before each time the room state is being sent to clients in particular room.

export class MyRoom extends Room<MyState> {
  // ...
  onBeforePatch(state: MyState) {
    console.log(state);
  }
  // ...
}

Schema: single property callback is now available on all platforms!

You can now listen to a particular property change on all platforms. This used to be possible only on JavaScript/TypeScript:

player.position.listen("x", (value, previousValue) => {/* "x" property changed */})
player.position.listen("y", (value, previousValue) => {/* "y" property changed */})

C# equivalent:

player.position.OnXChange((value, previousValue) => {/* "x" property changed */});
player.position.OnYChange((value, previousValue) => {/* "y" property changed */});

See full documentation.

Introduced log flag for incoming and outgoing messages

For aiding debugging, logging incoming and outgoing messages functionality has been added. You can enable it by using DEBUG=colyseus:messages environment variable. (See full documentation on debug messages)

DEBUG=colyseus:messages

Possibility to access a client directly through its sessionId

Previously, to retrieve a particular client by its sessionId, you'd need to filter it from the client list:

const opponent = this.clients.find((client) => client.sessionId === sessionId);

Now, you can access it directly:

const opponent = this.clients.get(sessionId);

Support for custom loggers

Node.js has many full-featured loggers, such as winston, bunyan, pino, etc. You can now leverage their functionality on internal Colyseus logs. If left unspecified, console is used as default logger.

See example below using winston:

import { Server } from "@colyseus/core";
import * as winston from "winston";

const gameServer = new Server({
    logger: winston.createLogger({
        format: winston.format.combine(
            winston.format.timestamp(),
            winston.format.json(),
        ),
        level: 'info',
        transports: [
            new winston.transports.File({ filename: 'error.log', level: 'error' }),
            new winston.transports.File({ filename: 'all.log' }),
        ],
    })
});

Consuming the logger:

To consume it, you must import logger from @colyseus/core, see example below:

import { Client, logger } from "@colyseus/core";

export class YourGameRoom extends Room {

  onCreate (options: any) {/* ... */}

  onJoin(client: Client, options: any) {
    logger.info(client.sessionId, "joined!");
  }

  onLeave (client: Client, consented: boolean) {
    logger.info(client.sessionId, "left!");
  }

  onDispose() {
    logger.info("room", this.roomId, "disposing...");
  }
}