From ac19ed3c1a6a2bb34295f80d8af120fb26f1fba7 Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Fri, 25 May 2018 13:34:27 +0200 Subject: [PATCH] tcp: better client storing --- app/main/osc/index.js | 4 ++-- app/main/osc/tcp.js | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/main/osc/index.js b/app/main/osc/index.js index 45110cae..bb1f1967 100644 --- a/app/main/osc/index.js +++ b/app/main/osc/index.js @@ -112,8 +112,8 @@ class OscServer { args: data.args }, data.host, data.port) - if (tcpInPort && oscTCPServer.clients[data.host + ':' + data.port]) { - oscTCPServer.clients[data.host + ':' + data.port].send({ + if (tcpInPort && oscTCPServer.clients[data.host] && oscTCPServer.clients[data.host][data.port]) { + oscTCPServer.clients[data.host][data.port].send({ address: data.address, args: data.args }) diff --git a/app/main/osc/tcp.js b/app/main/osc/tcp.js index bc44929b..9cab67d0 100644 --- a/app/main/osc/tcp.js +++ b/app/main/osc/tcp.js @@ -15,7 +15,6 @@ class OscTCPClient extends EventEmitter { this.options = options this.remoteAddress = options.address this.remotePort = options.port - this.name = this.remoteAddress + ':' + this.remotePort this.open() @@ -86,14 +85,15 @@ class OscTCPServer extends EventEmitter { addClient(client) { - this.clients[client.name] = client + this.clients[client.remoteAddress] = this.clients[client.remoteAddress] || {} + this.clients[client.remoteAddress][client.remotePort] = client client.on('message', (msg, timetag, info)=>{ this.emit('message', msg, timetag, info) }) client.on('die', (hadError)=>{ - delete this.clients[client.name] + if (this.clients[client.remoteAddress]) delete this.clients[client.remoteAddress][client.remotePort] }) }