(bus, port, host)
| 60 | } |
| 61 | |
| 62 | function 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 | |
| 95 | function RemoteClient(fn, callbacks) |
| 96 | { |
nothing calls this directly
no test coverage detected