Network Class
Network class.
This class represents transport between client link.js and server node-link. Network layer is websockets which support binary encoding of messages wisg msgpack.
Constructor
Network
(
-
config
Parameters:
-
config
Object
Example:
var network = new LINK.Network({binary: true});
network.onmessage(function (message) { console.log(message); });
network.onerror(function (error) { console.log("Error: " + error); });
network.onclose(function (error) { console.log("Closed: " + error); })
network.connect("localhost");
// some code later
network.close();
Methods
close
(
-
layerName
Creates new layer with name layerName above others layers.
Parameters:
-
layerName
String
connect
(
-
host
-
port
Creates new layer with name layerName above others layers.
Parameters:
-
host
String -
port
Number
onclose
(
-
callback
Creates new layer with name layerName above others layers.
Parameters:
-
callback
Function
onerror
(
-
callback
Creates new layer with name layerName above others layers.
Parameters:
-
callback
Function
onmessage
(
-
callback
Creates new layer with name layerName above others layers.
Parameters:
-
callback
Function
onopen
(
-
callback
Creates new layer with name layerName above others layers.
Parameters:
-
callback
Function
send
(
-
message
Creates new layer with name layerName above others layers.
Parameters:
-
message
Object