new Daemon(app, config, logger)
Create the service
Parameters:
| Name | Type | Description |
|---|---|---|
app |
App | Application |
config |
object | Configuration |
logger |
Logger | Logger service |
Members
-
<static> provides :string
-
Service name is 'servers.daemon'
Type:
- string
-
<static> requires :Array.<string>
-
Dependencies as constructor arguments
Type:
- Array.<string>
-
<static> requestTimeout :number
-
How much time to wait for tracker response
Type:
- number
Methods
-
<async> init(name)
-
Initialize the server
Parameters:
Name Type Description namestring Config section name Returns:
- Type
- Promise
-
<async> start(name)
-
Start the server
Parameters:
Name Type Description namestring Config section name Returns:
- Type
- Promise
-
<async> stop(name)
-
Stop the server
Parameters:
Name Type Description namestring Config section name Returns:
- Type
- Promise
-
send(id, data)
-
Send message
Parameters:
Name Type Description idstring Client ID dataBuffer | null Data to send -
onServerError(error)
-
Server error handler
Parameters:
Name Type Description errorobject The error -
onListening()
-
Server listening event handler
-
onConnection(socket)
-
Connection handler
Parameters:
Name Type Description socketobject Client socket -
onMessage(id, data)
-
Client message handler
Parameters:
Name Type Description idstring Client ID dataBuffer Message Returns:
Destroy socket on false- Type
- boolean
-
onError(id, error)
-
Client error handler
Parameters:
Name Type Description idstring Client ID errorError Error -
onClose(id)
-
Client disconnect handler
Parameters:
Name Type Description idstring Client ID