Skip to main content

NetworkClient

Index

Properties

auth

auth: unknown

Custom auth data associated with this NetworkClient. You may set this to anything.

canJoinFullRooms

canJoinFullRooms: boolean

Whether or not this client should bypass the client count check.

data

data: unknown

Custom data associated with this NetworkClient. You may set this to anything.

readonlyid

id: number

The id of this client

optionalroom

room?: Room

The room this client is in

status

status: ClientStatus = ClientStatus.CONNECTED

Connection status

Methods

close

  • close(code?: number, reason?: string): void
  • Disconnects a client


    Parameters

    • code: number = 0

      WebSocket close code

    • reason: string = null

      WebSocket close reason, also sent as a CloseReason to the client.

    Returns void

send

  • send<T, T2>(event: T, data: T2): void
  • Sends a message to this client


    Type parameters

    • T = string | number
    • T2 = string | number | object | Buffer

    Parameters

    • event: T

      Unique identifier for this event. See onMessage for more info about event identifiers.

    • data: T2

      Data that will be sent to this client.

    Returns void