Implements

Constructors

Properties

masterId: string = ''

One player will be selected as the master.

moveSyncInterval: number = 150

Synchronization frequency of player's movement. Default value is 150ms, the configurable range is 30ms to 150ms.

playerIdMap: {} = {}

Provide the IDs of all players and sort them.

Methods

  • Generate a message ID.

    Returns string

  • Planned

    Trigger game end early if conditions are met within the countdown.

    Returns void

  • Planned

    Trigger game start, begin countdown.

    Returns void

  • Send custom message.

    Type Parameters

    • T = Record<string, unknown>

    Parameters

    • message: T

      Custom message content.

    • Optionaloptions: {
          batch?: boolean;
          entityId?: string;
          messageId?: string;
      }

      Other options.

      • Optionalbatch?: boolean

        Batch processing of messages: If set to true, the messages will be cached and sent together later.

      • OptionalentityId?: string

        Entity GUID: Specifies the entity that can receive the message through the receive:message event.

      • OptionalmessageId?: string

        Message ID: Used to override messages with the same ID that have not been sent yet.

    Returns string

    • Message ID.
  • Planned

    Parameters

    • event: string

      Event name, can be customized as needed.

    • targetId: string

      Specified target ID, can be customized as needed. Specify a specific event and targetId, and let the server decide who is the owner (whoever sends the message first).

    Returns void

    // targetId is the entity ID.

    // Player A sends take-ownership event.
    sendOwnerUpdate('take-ownership', 'f47ac10b-58cb-11d1-a5f3-0000f8751022');

    // Player B sends take-ownership event.
    sendOwnerUpdate('take-ownership', 'f47ac10b-58cb-11d1-a5f3-0000f8751022');

    // Server decides Player A is the owner.
    // Notify all players that Player A is the owner.

    networkService.on('receive:ownerUpdate', (params) => {
    if (params.event === 'take-ownership') {
    // Player A is the owner, successor is Player A's ID.
    }
    })
MMNEPVFCICPMFPCPTTAAATR