diff --git a/axe.js b/axe.js index 19a00bce..dbcb9c0f 100644 --- a/axe.js +++ b/axe.js @@ -181,7 +181,8 @@ dht(soul, pids); Gun.obj.map(pids.split(','), function(pid) { /// TODO: here we can put an algorithm of who must connect? - if (!pid || pid in opt.peers || pid === opt.pid) { return; } + if (!pid || pid in opt.peers || pid === opt.pid || opt.announce[pid]) { return; } + opt.announce[pid] = true; /// To try only one connection to the same peer. opt.announce(pid); }); }); diff --git a/lib/webrtc.js b/lib/webrtc.js index 8e29cf32..62831c17 100644 --- a/lib/webrtc.js +++ b/lib/webrtc.js @@ -49,6 +49,7 @@ function open(msg){ var rtc = msg.rtc, peer, tmp; if(!rtc || !rtc.id){ return } + delete opt.announce[rtc.id]; /// remove after connect if(tmp = rtc.answer){ if(!(peer = opt.peers[rtc.id]) || peer.remoteSet){ return } return peer.setRemoteDescription(peer.remoteSet = new opt.RTCSessionDescription(tmp));