summaryrefslogtreecommitdiff
path: root/threads.js
diff options
context:
space:
mode:
Diffstat (limited to 'threads.js')
-rw-r--r--threads.js20
1 files changed, 12 insertions, 8 deletions
diff --git a/threads.js b/threads.js
index ba99cd7..fab636e 100644
--- a/threads.js
+++ b/threads.js
@@ -1324,6 +1324,8 @@ Process.prototype.doRemoveTemporaries = function () {
Process.prototype.sendPeerMessage = function (message, peer) {
var myself = this;
+ var stage = this.homeContext.receiver.parentThatIsA(StageMorph),
+ ide = this.homeContext.receiver.parentThatIsA(IDE_Morph);
if (peer instanceof List) {
peer.asArray().forEach(function (singlePeer) {
@@ -1331,10 +1333,12 @@ Process.prototype.sendPeerMessage = function (message, peer) {
});
return;
}
+ if (peer == ide.peer.id) {
+ stage.newPeerMessage(message, peer);
+ return;
+ }
- var stage = this.homeContext.receiver.parentThatIsA(StageMorph),
- ide = this.homeContext.receiver.parentThatIsA(IDE_Morph);
- var connection = stage.peer.connect(peer, {reliable: true});
+ var connection = ide.peer.connect(peer, {reliable: true});
connection.on('open', function () {
var data;
if (typeof message == "string") {
@@ -1352,11 +1356,11 @@ Process.prototype.reportPeerList = function () {
var myself = this;
if (!this.context.wait) {
- var stage = this.homeContext.receiver.parentThatIsA(StageMorph);
- stage.peer.listAllPeers(function (peers) {
+ this.context.wait = true;
+ var ide = this.homeContext.receiver.parentThatIsA(IDE_Morph);
+ ide.peer.listAllPeers(function (peers) {
myself.context.result = new List(peers);
});
- this.context.wait = true;
} else if (this.context.result) {
return this.context.result;
}
@@ -1366,8 +1370,8 @@ Process.prototype.reportPeerList = function () {
};
Process.prototype.reportPeerId = function () {
- var stage = this.homeContext.receiver.parentThatIsA(StageMorph);
- return stage.peerId;
+ var ide = this.homeContext.receiver.parentThatIsA(IDE_Morph);
+ return ide.peer.id;
};
// Process sprite inheritance primitives