Improve connect and disconnect with another instances

pull/263/head
Rodrigo Nascimento 11 years ago
parent 30a00d02dc
commit 46bead3d38
  1. 4
      server/stream/streamBroadcast.coffee

@ -6,14 +6,14 @@
InstanceStatus.getCollection().find().observe
added: (record) ->
if record.extraInformation.port is process.env.PORT
if record.extraInformation.port is process.env.PORT or connections[record.extraInformation.port]?
return
console.log 'connecting in', "localhost:#{record.extraInformation.port}"
connections[record.extraInformation.port] = DDP.connect("localhost:#{record.extraInformation.port}", {_dontPrintErrors: true})
removed: (record) ->
if connections[record.extraInformation.port]?
if connections[record.extraInformation.port]? and not InstanceStatus.getCollection().findOne({'extraInformation.port': {$ne: record.extraInformation.port}})?
console.log 'disconnecting from', "localhost:#{record.extraInformation.port}"
connections[record.extraInformation.port].disconnect()
delete connections[record.extraInformation.port]

Loading…
Cancel
Save