Interface INetworkServiceEvents

interface INetworkServiceEvents {
    connected: (() => void);
    error: (() => void);
    game:allPlayerReady: ((playerIdMap: {
        [index: number]: string;
    }) => void);
    game:countdown: ((second: number) => void);
    game:end: (() => void);
    game:masterNotify: ((masterId: string) => void);
    game:timer: ((second: number) => void);
    game:timeUp: (() => void);
    game:waitForPlayer: ((playerIdMap: {
        [index: number]: string;
    }) => void);
    receive:messages: ((messages: IMessage<Record<string, unknown>>[]) => void);
    receive:ownerUpdate: ((updateMessage: IOwnerUpdateMessage) => void);
    receive:trigger: ((triggerMessage: ITriggerMessage) => void);
}

Hierarchy

  • IBotGameEvents
  • IBotOwnerEvents
    • INetworkServiceEvents

Properties

connected: (() => void)

Triggered when the game successfully connects.

Type declaration

    • (): void
    • Returns void

error: (() => void)

Triggered when the game fails to connect.

Type declaration

    • (): void
    • Returns void

game:allPlayerReady: ((playerIdMap: {
    [index: number]: string;
}) => void)

Once the player count condition is met, notify all players that the game can start.

Type declaration

    • (playerIdMap): void
    • Parameters

      • playerIdMap: {
            [index: number]: string;
        }

        Provide the IDs of all players and sort them.

        • [index: number]: string

      Returns void

game:countdown: ((second: number) => void)

Trigger game start, begin countdown (currently only sends once).

Type declaration

    • (second): void
    • Parameters

      • second: number

        Game countdown time.

      Returns void

game:end: (() => void)

Game ends when conditions are met.

Type declaration

    • (): void
    • Returns void

game:masterNotify: ((masterId: string) => void)

Type declaration

    • (masterId): void
    • Parameters

      • masterId: string

        Notify which player is the master of the room.

      Returns void

game:timer: ((second: number) => void)

Game countdown during the game, sent at specified intervals.

Type declaration

    • (second): void
    • Parameters

      • second: number

        Game duration.

      Returns void

game:timeUp: (() => void)

Game ends when the game time is up.

Type declaration

    • (): void
    • Returns void

game:waitForPlayer: ((playerIdMap: {
    [index: number]: string;
}) => void)

Trigger when a player joins the game, notify all players to wait for others.

Type declaration

    • (playerIdMap): void
    • Parameters

      • playerIdMap: {
            [index: number]: string;
        }

        Provide the IDs of all players and sort them.

        • [index: number]: string

      Returns void

receive:messages: ((messages: IMessage<Record<string, unknown>>[]) => void)

Triggered when a custom message is received.

Type declaration

    • (messages): void
    • Parameters

      • messages: IMessage<Record<string, unknown>>[]

        Custom message

      Returns void

receive:ownerUpdate: ((updateMessage: IOwnerUpdateMessage) => void)

Triggered when owner update is received.

Type declaration

    • (updateMessage): void
    • Parameters

      • updateMessage: IOwnerUpdateMessage

        Event parameters, including event name, target ID, successful player, etc.

      Returns void

receive:trigger: ((triggerMessage: ITriggerMessage) => void)

Triggered when a trigger message is received.

Type declaration

    • (triggerMessage): void
    • Parameters

      Returns void