A collection of private functions, run automatically when the app starts, for creating our Koa app and HTTP and WS servers.
Methods
(private, inner) createTeamster()
Start 1 or more web processes running our app.
(private, inner) onClose(client)
Handle a client's socket closing.
Parameters:
| Name | Type | Description |
|---|---|---|
client |
Client | The client whose socket has closed. |
(private, inner) onConnection(socket)
Handle a newly connected WebSocket connection
Parameters:
| Name | Type | Description |
|---|---|---|
socket |
WS.WebSocket | The new WebSocket connection |
(private, inner) onMessage(client, message)
Handle a message sent by a client.
Parameters:
| Name | Type | Description |
|---|---|---|
client |
Client | The client that sent the message |
message |
string | The message sent by the client |
(private, inner) startServers()
Start HTTP and WS servers for our app.
(private, inner) startWSServer(httpServer)
Start a WS server for handling WebSocket connections.
Parameters:
| Name | Type | Description |
|---|---|---|
httpServer |
HTTP.Server | The httpServer to attach the WS server to |