From 46bead3d3891cfbad69ec132ecfe5125875a4fd8 Mon Sep 17 00:00:00 2001 From: Rodrigo Nascimento Date: Sat, 4 Jul 2015 11:12:49 -0300 Subject: [PATCH] Improve connect and disconnect with another instances --- server/stream/streamBroadcast.coffee | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/stream/streamBroadcast.coffee b/server/stream/streamBroadcast.coffee index a39f5d4169e..64d3d22123a 100644 --- a/server/stream/streamBroadcast.coffee +++ b/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]