Remember that this plugin has no protocol to structure requests and responses. Design your own protocol depending on your needs (e.g pub/sub).
Register tricep as a hapijs plugin with the following options:
server
- optional connection settings where values can be:port
- the port to listen to. Defaults to9876
.host
- the host to listen to. Defaults tolocalhost
.exclusive
- see the description here.
create
- optional server creation settings where values can be:onConnect(client)
- listener that will get invoked everytime a client connects where:client
- the net socket of the connecting client.
onError(err)
- listener that will get invoked when the server emits an error event where:err
- the error the socket will throw.
tricep exposes server.tricep
which represents the net server object. Additional operations that you can do are:
server.tricep.onConnect(client)
- same signature are theoptions.onConnect
. Override this if you want to have a different listener from what you initially assigned fromoptions.onConnect
.server.tricep.onError(err)
- same signature are theoptions.onError
. Override this if you want to have a different listener from what you initially assigned fromoptions.onError
.
Create a new tricep client.
Create a new client where:
settings
- optional port and host settings where values can be:port
- the port to listen to. Defaults to 9876.host
- the host to listen to. Defaults tolocalhost
.
The client net socket object.
Connects your client to the server where the parameters are:
settings
- optional server port and host settings where values can be:port
- the server port to connect to. Defaults to 9876.host
- the server host to connect to. Defaults tolocalhost
.
onConnect()
- optional callback to invoke after the client has connected to the server.
Override these to modify the event listeners of the client.
onConnect()
- listener that will get invoked when client successfully connects to the server.onDisconnect()
- listener that will get invoked when client disconnects from the server.onData(data)
- listener that will get invoked when client receives data from the server where:data
- the data from the server.
onError(err)
- listener that will get invoked when the client emits an error event where:err
- the error the socket will throw.