Skip to main content

Server

Index

Constructors

constructor

Methods

createRoom

  • createRoom(id: string, templateName: string): Room
  • Create a room with the specified template.

    @example
    const room = server.createRoom('my-room', 'my-game-mode');

    Parameters

    • id: string

      ID of the room

    • templateName: string

      Name of the room template

    Returns Room

    The created room

define

  • define(name: string, template: typeof Room, opts?: unknown): void
  • Define a room template. This is used to create rooms.

    @example
    server.define('my-game-mode', MyGameMode, { friendlyFire: true });

    Parameters

    • name: string

      Name of the room template

    • template: typeof Room

      Room class

    • optionalopts: unknown

      Options to pass to Room.init

    Returns void

destroyRoom

  • destroyRoom(room: Room): void
  • Destroy a room.


    Parameters

    • room: Room

      Room to destroy

    Returns void

listen

  • listen(port: number): void
  • Listen for connections on the specified port.


    Parameters

    • port: number

      Port to listen on

    Returns void