summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGubolin <gubolin@fantasymail.de>2015-03-08 16:13:29 +0100
committerGubolin <gubolin@fantasymail.de>2015-03-08 16:13:29 +0100
commit916dfe65e4afe636ce42e178fe88815b4b86026d (patch)
tree287c4bb73e89b51fc260eccf2795249e920c6a8f
parente3f7a47d95711effb8ab4b95b1c5fdde9178a72a (diff)
downloadsnap-916dfe65e4afe636ce42e178fe88815b4b86026d.tar.gz
snap-916dfe65e4afe636ce42e178fe88815b4b86026d.zip
another attempt to fix disconnect issues
-rw-r--r--objects.js13
-rw-r--r--threads.js6
2 files changed, 6 insertions, 13 deletions
diff --git a/objects.js b/objects.js
index 3a39a5c..b115b3b 100644
--- a/objects.js
+++ b/objects.js
@@ -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) {
diff --git a/threads.js b/threads.js
index 165c7fc..d8ec04f 100644
--- a/threads.js
+++ b/threads.js
@@ -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