diff options
| author | Gubolin <gubolin@fantasymail.de> | 2015-03-08 16:13:29 +0100 |
|---|---|---|
| committer | Gubolin <gubolin@fantasymail.de> | 2015-03-08 16:13:29 +0100 |
| commit | 916dfe65e4afe636ce42e178fe88815b4b86026d (patch) | |
| tree | 287c4bb73e89b51fc260eccf2795249e920c6a8f | |
| parent | e3f7a47d95711effb8ab4b95b1c5fdde9178a72a (diff) | |
| download | snap-yow-916dfe65e4afe636ce42e178fe88815b4b86026d.tar.gz snap-yow-916dfe65e4afe636ce42e178fe88815b4b86026d.zip | |
another attempt to fix disconnect issues
| -rw-r--r-- | objects.js | 13 | ||||
| -rw-r--r-- | threads.js | 6 |
2 files changed, 6 insertions, 13 deletions
@@ -4426,11 +4426,9 @@ StageMorph.prototype.init = function (globals) { StageMorph.prototype.initPeering = function (id) { var myself = this; - if (window.peers) { + if (window.peer) { // I don't know why, but it works. - while (window.peers.length > 0) { - window.peers.pop().destroy(); - } + window.peer.destroy(); } this.peer = new Peer(id, { @@ -4440,13 +4438,10 @@ StageMorph.prototype.initPeering = function (id) { path: '/' }); - this.peer.on('open', function (id) { - myself.peerId = id; - }); this.peer.on('disconnected', function () { // peer.reconnect does not work (?) because 'id' is undefined if (!myself.peer.destroyed) { - myself.initPeering(myself.peerId); + myself.initPeering(myself.peer.id); } }); this.peer.on('error', function (err) { @@ -4461,7 +4456,7 @@ StageMorph.prototype.initPeering = function (id) { }); }); - window.peers.push(this.peer); + window.peer = this.peer; }; StageMorph.prototype.newPeerMessage = function (data, peer) { @@ -1302,15 +1302,13 @@ Process.prototype.sendPeerMessage = function (message, peer) { var stage = this.homeContext.receiver.parentThatIsA(StageMorph), ide = this.homeContext.receiver.parentThatIsA(IDE_Morph); - console.log(peer, stage.peerId); if (peer instanceof List) { peer.asArray().forEach(function (singlePeer) { myself.sendPeerMessage(message, singlePeer); }); return; } - if (peer == stage.peerId) { - console.log('hello self!'); + if (peer == stage.peer.id) { stage.newPeerMessage(message, peer); return; } @@ -1348,7 +1346,7 @@ Process.prototype.reportPeerList = function () { Process.prototype.reportPeerId = function () { var stage = this.homeContext.receiver.parentThatIsA(StageMorph); - return stage.peerId; + return stage.peer.id; }; // Process lists primitives |
