How to use the colyseus.serialize function in colyseus

To help you get started, we’ve selected a few colyseus 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 colyseus / colyseus-monitor / example / ChatRoom.ts View on Github external
import { Room, FossilDeltaSerializer, serialize } from "colyseus";

@serialize(FossilDeltaSerializer)
export class ChatRoom extends Room {
  maxClients = 4;

  onInit (options) {
    this.setState({ messages: [] });
  }

  async onAuth (options) {
    return { success: true };
  }

  onJoin (client, options, auth) {
    this.state.messages.push(`${ client.id } joined.`);
  }

  requestJoin (options, isNewRoom: boolean) {