tcp: better client storing
This commit is contained in:
parent
72c3973f05
commit
ac19ed3c1a
2 changed files with 5 additions and 5 deletions
|
|
@ -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
|
||||
})
|
||||
|
|
|
|||
|
|
@ -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]
|
||||
})
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue