Class RAIServer
- Defined in: rai.js
Constructor Attributes | Constructor Name and Description |
---|---|
RAIServer(options)
Creates instance of RAIServer Options object has the following properties:
Events
|
Method Summary
Class Detail
RAIServer(options)
Creates instance of RAIServer
Options object has the following properties:
- debug - if set to true print traffic to console
- disconnectOnTimeout - if set to true close the connection on disconnect
- timeout - timeout in milliseconds for disconnecting the client, defaults to 0 (no timeout)
Events
- 'connect' - emitted if a client connects to the server, param is a client (RAISocket) object
- 'error' - emitted on error, has an error object as a param
- Parameters:
- {Object} options Optional
- Optional options object
Method Detail
-
<private> _createServer()
Creates a server with listener callback
-
<private> _serverListener(socket)
Server listener that is run on client connection
RAISocket object instance is created based on the client socket and a
'connection'
event is emitted- Parameters:
- {Object} socket
- The socket to the client
-
end(callback)
Stops the server
- Parameters:
- {Function} callback
- Is run when the server is closed
-
listen(port, host, callback)
Starts listening on selected port
- Parameters:
- {Number} port
- The port to listen
- {String} host Optional
- The IP address to listen
- {Function} callback
- The callback function to be run after the server is listening, the only param is an error message if the operation failed
Event Detail
<private>
_onError(err)
Listens for errors
- Parameters:
- {Object} err
- Error object