Hierarchy

  • Engine

Constructors

Properties

Accessors

Methods

Constructors

Properties

CONNECT_INTENT_POST_INTERVAL: number = ...
LOG_THRESH_MS: number = 10000
_bufferedAmounts: SlidingWindow = ...
_byteTrackerInterval: TimeoutOrUndefined
_bytesReceivedSinceConnect: number = 0
_bytesSentSinceConnect: number = 0
_closeCounts: {
    [code: number]: number;
} = {}

Type declaration

  • [code: number]: number
_connected: boolean = false
_eventCountsSinceOpen: {
    [event: string]: number;
} = {}

Type declaration

  • [event: string]: number
_heartbeatInterval: TimeoutOrUndefined
_lastActionSentAt: number = 0
_lastBackupHeartbeatSent: number = 0
_lastBytesReceived: number = 0
_lastBytesSent: number = 0
_lastRegularHeartbeatSent: number = 0
_reconnectionAttempts: number = 0
_sendQ: {
    action: ClientServerActionAction;
    txnId?: number;
}[] = []
_timeSpentDisconnected: SlidingWindow = ...
clientUid?: string
connectIntentInterval: TimeoutOrUndefined
connectMetrics: {
    gotGameServerUrl: number;
    gotReady: number;
    gotSpaceSetsCapacity: number;
    gotSpaceSetsIdMapping: number;
    gotSubscriptionsUpdated: number;
    gotWsOpen: number;
} = ...

Type declaration

  • gotGameServerUrl: number
  • gotReady: number
  • gotSpaceSetsCapacity: number
  • gotSpaceSetsIdMapping: number
  • gotSubscriptionsUpdated: number
  • gotWsOpen: number
connectionFailedTimeout: TimeoutOrUndefined
connectionId: string = ""
connectionInitTime: number = 0
dcLogTimeout: TimeoutOrUndefined
debugOverrideHttpServer?: string
debugOverrideServer?: string
disconnectedStartTime: number = 0
getAuth: (() => Promise<EngineAuth>)

Type declaration

gotFirstMessage: boolean = false
hasEverFullyConnected: boolean = false
lastSignOfLife: number = 0
lastSuccessfulFetch: number = 0
lastSuspendCheck: number = 0
lastSuspendDate: number = 0
latencies: SlidingWindow = ...
numMoveEventsBuffered: number = 0
preRefreshDcData: undefined | EngineUnloadDcData = undefined
reconnectTimeout: TimeoutOrUndefined
serverURL: string = ""
sizeOfLargestMessageReceived: number = 0
sizeOfNextLargeMessage: number = 0
spaceId: string
startTime: number = 0
started: boolean = false
suspendCheckInterval: TimeoutOrUndefined
tempInitInfo?: PlayerInitInfo
tempSpawnToken?: string
tempTargetId?: string
transactionManager: TransactionManager = ...
uninterruptedLastFullSyncTime: number = 0
uploadLogTimeout: TimeoutOrUndefined
uploadLogTimeoutLong: TimeoutOrUndefined
userIdForABTest: string = ""
wantsToEnter: boolean = false
  • action/event handling **
ws?: WebSocket

Accessors

Methods

    • UTILS **

    Returns {
        connectionId: string;
        serverUrl: string;
    }

    • connectionId: string
    • serverUrl: string
  • Returns the serverURL for the spaceId or null in case of timeout/error

    Parameters

    • signal: AbortSignal

    Returns Promise<null | string>

  • Returns {
        bufferedAmount: SlidingWindowMetrics;
        bytesReceivedSinceConnect: number;
        bytesSentSinceConnect: number;
        closeCodeCount: {
            [code: number]: number;
        };
        connected: boolean;
        eventCountsSinceOpen: {
            [event: string]: number;
        };
        latency: SlidingWindowMetrics;
        reconnects: {
            recentAttempts: number;
            timeSpentDisconnectedMs: SlidingWindowMetrics;
        };
    }

    • bufferedAmount: SlidingWindowMetrics
    • bytesReceivedSinceConnect: number
    • bytesSentSinceConnect: number
    • closeCodeCount: {
          [code: number]: number;
      }
      • [code: number]: number
    • connected: boolean
    • eventCountsSinceOpen: {
          [event: string]: number;
      }
      • [event: string]: number
    • latency: SlidingWindowMetrics
    • reconnects: {
          recentAttempts: number;
          timeSpentDisconnectedMs: SlidingWindowMetrics;
      }
  • try to load the last disconnected unload state to detect whether the user refreshed their browser

    Returns void

  • Parameters

    Returns Promise<unknown>

    A promise if createTxnId is true, otherwise nothing.

  • Parameters

    • action: ClientServerActionAction
    • Optional bypass: boolean
    • Optional createTxnId: false
    • Optional txnId: number
    • Optional txnTimeout: number

    Returns void

  • Parameters

    • action: ClientServerActionAction
    • Optional bypass: boolean
    • Optional createTxnId: boolean
    • Optional txnId: number
    • Optional txnTimeout: number

    Returns void | Promise<unknown>

  • CONNECTION LOGIC

    lifecycle is now:

    • start / stop -- for making the engine do anything at all
    • createConnection / destroyConnection -- internal to engine. for managing the specific connection at any given time
    • cleanUpAndQueueReconnect -- for reconnects

    connection attempt flow (in this.createConnection):

    • fetch game server assignment (ws url) from https://api.gather.town/api/v2/spaces/${spaceId}/game-server-assignment
    • open ws connection to that^ url (e.g. wss://game-aaai-xxx.gather.town:443)
    • connection opens successfully
    • receive all init data (maps and players) if any of those steps fail, we reset everything, wait an exponential backoff, and try again

    reconnect/retry safeguards:

    • if the connection closes, clean up (destroy) and queue reconnect
    • start a timeout when you first try to connect, cancel it when you get the first message. destroys and queues reconnect if it goes off (MAX_WAIT_FOR_CONNECTION)
    • start a heartbeat when you open the connection. if you don't hear anything for a while, destroy and queue reconnect (HEARTBEAT_TIMEOUT)
    • cleanUpAndQueueReconnect sets a timeout to create a new connection, if one doesn't exist already
      • timeout length increases (up to MAX_RECONNECT_DELAY) each time until it's been a while (RESET_RECONNECT_ATTEMPTS_DELAY) since last call to reconnect

    Returns void

Generated using TypeDoc