SocketServer performs all the necessary work around sockets and notifies the main Server of any changes (players, lobbies... )

The idea behind separating it is to provide a clean interface to the socket, and preserve all the server functionality independent of it. Testing should become easier because of that for example.

### Hierarchy

- SocketServer

## Index

### Constructors

- constructor

### Properties

- io
- socketEvents

### Methods

- emit
- emitInLobby
- emitPayload
- emitToLobbyInfo
- handler

## Constructors

### constructor

- new SocketServer(port: number, socketEvents: ISocketEvents): SocketServer

- - Defined in server/SocketServer.ts:37

  #### Parameters

  - ##### port: number

  - ##### socketEvents: ISocketEvents

  #### Returns SocketServer

## Properties

### Private io

io: Server

- Defined in server/SocketServer.ts:36

### Private socketEvents

socketEvents: ISocketEvents

- Defined in server/SocketServer.ts:37

## Methods

### emit

- emit(type: string, data: object): void

- - Defined in server/SocketServer.ts:159

  Send a message to any client listening on the socket

  #### Parameters

  - ##### type: string

    Message type (determines who receives the data)

  - ##### data: object

    Data to be sent

    - ##### payload: any

    - ##### type: string

  #### Returns void

### emitInLobby

- emitInLobby(lobby: string, type: string, data: any): void

- - Defined in server/SocketServer.ts:169

  Send a message to a lobby

  #### Parameters

  - ##### lobby: string

    Lobby token

  - ##### type: string

    Message type (determines who receives the data)

  - ##### data: any

    Data to be sent

  #### Returns void

### emitPayload

- emitPayload(emitType: string, type: string, payload: any): void

- - Defined in server/SocketServer.ts:183

  #### Parameters

  - ##### emitType: string

  - ##### type: string

  - ##### payload: any

  #### Returns void

### emitToLobbyInfo

- emitToLobbyInfo(lobby: string, type: string, data: any): void

- - Defined in server/SocketServer.ts:179

  Send a message to spectators in the lobby

  #### Parameters

  - ##### lobby: string

    Lobby token

  - ##### type: string

    Message type (determines who receives the data)

  - ##### data: any

    Data to be sent

  #### Returns void

### Private handler

- handler(req: IncomingMessage, res: ServerResponse): void

- - Defined in server/SocketServer.ts:193

  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

Generated using TypeDoc