Options
All
  • Public
  • Public/Protected
  • All
Menu

GameManager 负责游戏房间的分配

Type parameters

Hierarchy

  • EventEmitter
    • GameManager

Index

Constructors

constructor

  • new GameManager(__namedParameters: object): GameManager

Properties

Protected appId

appId: string

Protected appKey

appKey: string

Protected gameConstructor

gameConstructor: IGameConstructor<T>

Protected games

games: Set<T> = new Set<T>()

open

open: boolean = true

Protected playServer

playServer: string | undefined

Protected queue

queue: PQueue

Protected reservationHoldTime

reservationHoldTime: number

Static defaultMaxListeners

defaultMaxListeners: number

Static errorMonitor

errorMonitor: keyof symbol

This symbol shall be used to install a listener for only monitoring 'error' events. Listeners installed using this symbol are called before the regular 'error' listeners are called.

Installing a listener using this symbol does not change the behavior once an 'error' event is emitted, therefore the process will still crash if no regular 'error' listener is installed.

Accessors

Protected availableGames

  • get availableGames(): T[]

load

  • get load(): number

Methods

Protected addGame

  • addGame(game: T): void

addListener

  • addListener(event: string | symbol, listener: function): this
  • Parameters

    • event: string | symbol
    • listener: function
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

close

  • close(): Promise<any[]>

Protected createEmptyGame

createGame

  • 创建一个新的游戏。

    Parameters

    • playerId: string

      预留位置的的玩家 ID

    • Optional options: ICreateGameOptions

      配置项,详见其类型说明

    Returns Promise<T>

Protected createMasterClient

  • createMasterClient(id?: string): Client
  • 创建一个新的 masterClient

    Parameters

    • Default value id: string = generateId()

      指定 masterClient id

    Returns Client

emit

  • emit(event: string | symbol, ...args: any[]): boolean
  • Parameters

    • event: string | symbol
    • Rest ...args: any[]

    Returns boolean

eventNames

  • eventNames(): Array<string | symbol>
  • Returns Array<string | symbol>

getAvailableGames

  • getAvailableGames(availableSeatCount?: number): T[]
  • 获取可用的游戏列表

    Parameters

    • Default value availableSeatCount: number = 1

      可用空位数量,只返回大于等于这个数量的游戏

    Returns T[]

getMaxListeners

  • getMaxListeners(): number
  • Returns number

getStatus

  • getStatus(): Promise<object>

listenerCount

  • listenerCount(event: string | symbol): number
  • Parameters

    • event: string | symbol

    Returns number

listeners

  • listeners(event: string | symbol): Function[]
  • Parameters

    • event: string | symbol

    Returns Function[]

off

  • off(event: string | symbol, listener: function): this
  • Parameters

    • event: string | symbol
    • listener: function
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

on

  • on(event: string | symbol, listener: function): this
  • Parameters

    • event: string | symbol
    • listener: function
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

once

  • once(event: string | symbol, listener: function): this
  • Parameters

    • event: string | symbol
    • listener: function
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

prependListener

  • prependListener(event: string | symbol, listener: function): this
  • Parameters

    • event: string | symbol
    • listener: function
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

prependOnceListener

  • prependOnceListener(event: string | symbol, listener: function): this
  • Parameters

    • event: string | symbol
    • listener: function
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

rawListeners

  • rawListeners(event: string | symbol): Function[]
  • Parameters

    • event: string | symbol

    Returns Function[]

Protected remove

  • remove(game: T): void

removeAllListeners

  • removeAllListeners(event?: string | symbol): this
  • Parameters

    • Optional event: string | symbol

    Returns this

removeListener

  • removeListener(event: string | symbol, listener: function): this
  • Parameters

    • event: string | symbol
    • listener: function
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

Protected reserveSeats

  • reserveSeats(game: T, playerId: string): void

setMaxListeners

  • setMaxListeners(n: number): this
  • Parameters

    • n: number

    Returns this

Static listenerCount

  • listenerCount(emitter: EventEmitter, event: string | symbol): number
  • deprecated

    since v4.0.0

    Parameters

    • emitter: EventEmitter
    • event: string | symbol

    Returns number

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Type alias with type parameter
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method

Generated using TypeDoc