Options
All
  • Public
  • Public/Protected
  • All
Menu

Online Server class Handles the sockets, players, games...

Hierarchy

  • OnlineServer

Index

Constructors

constructor

Properties

Private games

games: Array<Game>

Current games being played

Private host

host: string

Server host

Private io

io: Server

Socket.IO Server reference

Private nextGame

nextGame: number

Index of the next game that will be played

Private players

players: Array<string>

List of players in the server

Private port

port: number

Server port

Private Optional ui

ui: GUI

Optional reference to the server GUI (if it has been enabled in the options)

Methods

Private addPlayer

  • addPlayer(player: string): number
  • Add a player to the server

    Parameters

    • player: string

      Player token

    Returns number

    Player index in the player list

Private handler

  • handler(req: IncomingMessage, res: ServerResponse): void
  • Handler for the WebSocket server. It returns a static HTML file for any request that links to the server documentation and Github page.

    Parameters

    • req: IncomingMessage
    • res: ServerResponse

    Returns void

Private log

  • log(message: string, skipRender?: boolean): void
  • Log a message to the console or the GUI if it's enabled

    Parameters

    • message: string
    • Default value skipRender: boolean = false

      only for GUI mode, set to true to avoid rerendering

    Returns void

Private removePlayer

  • removePlayer(player: string): void
  • Remove a player from the server

    Parameters

    • player: string

      Player token

    Returns void

Private startSession

  • startSession(session: Game, settings?: Options): void
  • Take a game holder with two connected players and start playing

    Parameters

    • session: Game

      Game session with two active players ready

    • Default value settings: Options = {}

      Server options

    Returns void

Generated using TypeDoc