diff --git a/CHANGELOG.md b/CHANGELOG.md index 1998e1ce..96c37158 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,9 @@ - on Mac, start hidden if `Start minimized` is set - allow dropping files into file fields +- custom module + - expose `tcpServer` to allow monitoring the state of tcp connections + ## 1.25.7 - bug fixes diff --git a/resources/docs/docs/custom-module/custom-module.md b/resources/docs/docs/custom-module/custom-module.md index f728e29e..6faeff91 100644 --- a/resources/docs/docs/custom-module/custom-module.md +++ b/resources/docs/docs/custom-module/custom-module.md @@ -135,6 +135,22 @@ This function can be used to load native node modules or locally installed modul ---- +#### `tcpServer` + +Raw access to the server's [TCP backend](https://github.com/jean-emmanuel/open-stage-control/blob/master/src/server/osc/tcp.js). Can be used to monitor the state of TCP connections: + +```js +for (var ip in tcpServer.clients) { + tcpServer.clients[ip].port.on('ready', ()=>{ + console.log(`TCP connection established with ${ip}:${tcpServer.clients[ip].remotePort}`) + }) + tcpServer.clients[ip].port.on('close', ()=>{ + console.log(`TCP connection lost with ${ip}:${tcpServer.clients[ip].remotePort}`) + }) +} +``` + + #### Other javascript globals - `console` diff --git a/src/server/osc/index.js b/src/server/osc/index.js index d72562b7..1126c2cf 100644 --- a/src/server/osc/index.js +++ b/src/server/osc/index.js @@ -18,6 +18,7 @@ class OscServer { this.customModuleEventEmitter = new EventEmitter() this.customModule = settings.read('custom-module') ? new CustomModule(settings.read('custom-module'), { app: this.customModuleEventEmitter, + tcpServer: oscTCPServer, sendOsc: this.sendOsc.bind(this), receiveOsc: this.receiveOsc.bind(this), send: (host, port, address, ...args)=>{