MCPcopy Create free account
hub / github.com/ajlopez/SimpleBus / Server

Function Server

lib/simplebus.js:62–93  ·  view source on GitHub ↗
(bus, port, host)

Source from the content-addressed store, hash-verified

60}
61
62function Server(bus, port, host) {
63 var server;
64 var clients = [];
65 var nclient = 0;
66
67 this.start = function () {
68 server = simpleremote.createRemoteServer(new RemoteServer(bus, clients));
69
70 server.on('remote', function (newclient) {
71 var id = ++nclient;
72 registerClient(id, newclient);
73 newclient.setId(id);
74 });
75
76 server.listen(port, host);
77 }
78
79 this.stop = function () {
80 if (server) {
81 server.close();
82 server = null;
83 }
84 }
85
86 function registerClient(id, client) {
87 clients[id] = client;
88 }
89
90 function unregisterClient(id) {
91 delete clients[id];
92 }
93}
94
95function RemoteClient(fn, callbacks)
96{

Callers

nothing calls this directly

Calls 1

registerClientFunction · 0.85

Tested by

no test coverage detected