Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Multiplayer

Hierarchy

Implements

Index

Constructors

constructor

  • Returns Multiplayer

Properties

Readonly event

event: IEventEmitter<this, IMultiplayerEvents> = new EventEmitter<this, E>(this)

Methods

addAfterSyncChecks

  • addAfterSyncChecks(packet: IPacket): void
  • Parameters

    Returns void

addBeforeSyncChecks

  • addBeforeSyncChecks(packet: IPacket): void
  • Parameters

    Returns void

addKeepAliveTimeouts

  • addKeepAliveTimeouts(): void
  • Returns void

addMiscSeedSyncCheck

  • addMiscSeedSyncCheck(...messages: any[]): void
  • Parameters

    • Rest ...messages: any[]

    Returns void

addSyncCheck

  • Parameters

    Returns void

checkConnection

  • checkConnection(): void
  • Returns void

clearKeepAliveTimeouts

  • clearKeepAliveTimeouts(): void
  • Returns void

clearSyncPacketWaiting

  • clearSyncPacketWaiting(packet: IPacket, wait: number): void
  • Parameters

    Returns void

clearSyncPacketsWaiting

  • clearSyncPacketsWaiting(waitId?: undefined | string): void
  • Parameters

    • Optional waitId: undefined | string

    Returns void

closeConnection

convertGameCodeToServerInfo

  • convertGameCodeToServerInfo(gameCode: string): ServerInfo
  • Parameters

    • gameCode: string

    Returns ServerInfo

createServer

  • Parameters

    Returns void

disconnect

  • Parameters

    • Optional reason: DisconnectReason
    • Default value args: any[] = []
    • Default value unloadingOrResetGameState: boolean = false

    Returns Promise<void>

disconnectAndResetGameState

displayJoinServerRetryDialog

enableSteamNetworkConnections

  • enableSteamNetworkConnections(enable: boolean): void
  • Parameters

    • enable: boolean

    Returns void

getBannedPlayers

  • getBannedPlayers(): string[]
  • Returns string[]

getClients

  • Returns IConnection[]

getConnectedGameCode

  • getConnectedGameCode(): string | undefined
  • Three types of game codes:

    1. Dedicated server code - ex. 1.2.3.4:1234
    2. Steam lobby code - ex. steam:109775241017071190
    3. Global matchmaking server id - ex. 87287724-49aa-e556-4145-3ed96c649a20

    Returns string | undefined

getConnectedMatchmakingInfo

  • Returns IMatchmakingInfo | undefined

getDedicatedServerMatchmakingInfo

  • getDedicatedServerMatchmakingInfo(matchmakingServer: string, identifier?: string): IMatchmakingInfo
  • Parameters

    • matchmakingServer: string
    • Default value identifier: string = UUID.create()

    Returns IMatchmakingInfo

getOptions

getPlayerIdentifier

  • getPlayerIdentifier(): string
  • Returns string

isClient

  • isClient(): boolean
  • Returns boolean

isConnected

  • isConnected(): boolean
  • Returns boolean

isProcessingPacket

  • isProcessingPacket(): boolean
  • Returns boolean

isReady

  • isReady(): boolean
  • Returns boolean

isServer

  • isServer(): boolean
  • Returns boolean

isSteamLobby

  • isSteamLobby(gameCode: string): boolean
  • Parameters

    • gameCode: string

    Returns boolean

isSyncCheckEnabled

  • Parameters

    Returns boolean

joinServer

  • Parameters

    Returns void

kick

  • Parameters

    Returns void

markCurrentProcessingPacket

  • markCurrentProcessingPacket(packetId: number, processing: boolean): void
  • Parameters

    • packetId: number
    • processing: boolean

    Returns void

onLobbyEntered

  • onLobbyEntered(success: boolean, lobbyId: string): void
  • Parameters

    • success: boolean
    • lobbyId: string

    Returns void

onLobbyExited

  • onLobbyExited(lobbyId: string): void
  • Parameters

    • lobbyId: string

    Returns void

onPlaying

  • Returns Promise<void>

pauseIncomingPacketProcessing

  • pauseIncomingPacketProcessing(pause: boolean, clearQueue?: undefined | false | true): void
  • Parameters

    • pause: boolean
    • Optional clearQueue: undefined | false | true

    Returns void

removePlayer

removePlayers

  • Parameters

    Returns void

requestReconnections

  • requestReconnections(): void
  • Returns void

sendConnectPacket

  • sendConnectPacket(): void
  • Returns void

sendPacket

  • Parameters

    Returns void

sendPacketTo

  • Parameters

    Returns void

setBanned

  • setBanned(identifier: string, ban: boolean): boolean
  • Parameters

    • identifier: string
    • ban: boolean

    Returns boolean

setOptions

  • Parameters

    Returns void

suppressSyncChecks

  • suppressSyncChecks(suppress: boolean): void
  • Parameters

    • suppress: boolean

    Returns void

syncGameState

  • syncGameState(): void
  • Returns void

syncPacket

  • syncPacket<T>(packet: IPacket, clientSide?: NullaryFunction<T>, checkId?: undefined | false | true, wait?: number | true): T | undefined
  • Sends a packet in a synchronized way to the server or clients

    When ran as a server, clientSide() is called and the packet data is sent to all the clients.

    When ran as a client, the packet is sent to the server. The server is expected to call this method, which in turn sends the packet back to the client. When the client receives the packet, this method a second time and clientSide() is called.

    Type parameters

    • T

    Parameters

    • packet: IPacket

      The packet

    • Optional clientSide: NullaryFunction<T>

      The method to run for the client or server.

    • Optional checkId: undefined | false | true

      When true, this packet will not be sent to the server/client if the same packet is already being processed. When false, this packet will not be sent if any packet is already being processed. Useful when dealing with methods that could end up sending multiple packets while a packet is already being processed.

    • Optional wait: number | true

      When true, the client will keep track of what packets it sent to the server. If the client calls this method again before the server responds, it will not send a duplicate packet. It will wait for the server to send the packet back before allowing another one to be sent. When true, it will keep track of duplicate packets based on the packet type. When it's a number, it will keep track of duplicate packets based on the packet type + the number.

    Returns T | undefined

updateGlobalServerDirectory

  • updateGlobalServerDirectory(): void
  • Returns void

updateOptions

  • Parameters

    Returns void

updatePlayerId

  • updatePlayerId(oldPid: number, newPid: number): void
  • Parameters

    • oldPid: number
    • newPid: number

    Returns void

Generated using TypeDoc