custom-module: expose tcpServer

This commit is contained in:
jean-emmanuel 2024-02-21 10:51:50 +01:00
parent fbfa41bd5a
commit 3ed11f3894
3 changed files with 20 additions and 0 deletions

View file

@ -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

View file

@ -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`

View file

@ -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)=>{