Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ClientEvent

ClientEvent is a simple data class used to pass information from a Client object to registered event-listeners when a client event occurs. The ClientEvent class also defines constants representing the available client events.

To register for a client event, use the Client.addEventListener method.

Hierarchy

  • Event
    • ClientEvent

Index

Constructors

constructor

  • Parameters

    • type: string
    • Optional changedAttr: Attribute
    • Optional room: Room
    • Optional roomID: undefined | string
    • Optional client: Client
    • Optional status: Status
    • Optional clientID: undefined | string

    Returns ClientEvent

Properties

Optional target

target: EventDispatcher

type

type: string

Static Readonly JOIN_ROOM

JOIN_ROOM: "JOIN_ROOM" = "JOIN_ROOM"

Dispatched when the client that triggered this event joins a room.

Static Readonly LEAVE_ROOM

LEAVE_ROOM: "LEAVE_ROOM" = "LEAVE_ROOM"

Dispatched when the client that triggered this event leaves a room. This event also occurs when a room containing the target client is removed, forcing the client to leave.

Static Readonly OBSERVE

OBSERVE: "OBSERVE" = "OBSERVE"

Dispatched when the current client observes a client. The client that is now being observed can be accessed via ClientEvent.getClient method.

Static Readonly OBSERVE_RESULT

OBSERVE_RESULT: "OBSERVE_RESULT" = "OBSERVE_RESULT"

Dispatched when the result of an earlier Client.observe or ClientManager.observeClient request is received.

Static Readonly OBSERVE_ROOM

OBSERVE_ROOM: "OBSERVE_ROOM" = "OBSERVE_ROOM"

Dispatched when the client that triggered this event observes a room.

Static Readonly STOP_OBSERVING

STOP_OBSERVING: "STOP_OBSERVING" = "STOP_OBSERVING"

Dispatched when the current client stops observing a client. The client that is no longer being observed can be accessed via ClientEvent.getClient method.

Static Readonly STOP_OBSERVING_RESULT

STOP_OBSERVING_RESULT: "STOP_OBSERVING_RESULT" = "STOP_OBSERVING_RESULT"

Dispatched when the result of an earlier Client.stopObserving or [[ClientManager.stopObservingClient]] request is received.

Static Readonly STOP_OBSERVING_ROOM

STOP_OBSERVING_ROOM: "STOP_OBSERVING_ROOM" = "STOP_OBSERVING_ROOM"

Dispatched when the client that triggered this event stops observing a room. This event also occurs when a room containing the client is removed, forcing the client to stop observing the room.

Static Readonly SYNCHRONIZE

SYNCHRONIZE: "SYNCHRONIZE" = "SYNCHRONIZE"

Dispatched when the client that triggered this event has been synchronized to match the state of the server due to an earlier observe() request.

Methods

getClient

  • Returns the Client object pertaining to this client event (for example, the client that was observed). The getClient() method is required only when the target of the ClientEvent is ClientManager; when the target of a ClientEvent is a Client object, the event's target property provides access to the Client object.

    Returns Client | null

getClientID

  • getClientID(): string | null
  • Returns the clientID of the client to which this event pertains. For example, for the ClientEvent.JOIN_ROOM event, getClientID() returns the id of the client that joined the room.

    Returns string | null

getRoom

  • getRoom(): Room | null
  • Returns the Room object pertaining to this client event (for example, the room that was joined or left).

    Returns Room | null

getRoomID

  • getRoomID(): string | null
  • Returns the fully qualified room ID for the Room object pertaining to this client event (for example, the room that was joined or left).

    Returns string | null

getStatus

  • Returns the status of the operation to which this event pertains.

    The getStatus() method's return value is always one of the Status class's constants. For example, if the ClientEvent.JOIN_RESULT event occurs in response to a successful room-join attempt, getStatus() will return the value of Status.SUCCESS.

    To respond to a status, compare the return of getStatus() to one of the Status constants.

    For a list of specific status values that can be returned during a particular event, see the documentation for that event.

    Returns Status | null