summaryrefslogtreecommitdiff
path: root/threads.js
diff options
context:
space:
mode:
authorGubolin <gubolin@fantasymail.de>2015-03-08 09:54:57 +0100
committerGubolin <gubolin@fantasymail.de>2015-03-08 09:54:57 +0100
commit526a595c5e00f171eb814f063e58a6c18c5784d4 (patch)
tree7043e1fe7a6d2434fc6e2072961948bb2c3e44dd /threads.js
parent1ed98c27ff3c1a825e75783481a4e739fb610bdb (diff)
parentb6d846444e44d41842e253b7276cd590d7163349 (diff)
downloadsnap-526a595c5e00f171eb814f063e58a6c18c5784d4.tar.gz
snap-526a595c5e00f171eb814f063e58a6c18c5784d4.zip
Merge branch 'development' into gh-pages
Diffstat (limited to 'threads.js')
-rw-r--r--threads.js54
1 files changed, 52 insertions, 2 deletions
diff --git a/threads.js b/threads.js
index 9af4d7f..0e3df5c 100644
--- a/threads.js
+++ b/threads.js
@@ -83,7 +83,7 @@ ArgLabelMorph, localize, XML_Element, hex_sha512*/
// Global stuff ////////////////////////////////////////////////////////
-modules.threads = '2015-January-12';
+modules.threads = '2015-February-28';
var ThreadManager;
var Process;
@@ -1320,6 +1320,56 @@ Process.prototype.doRemoveTemporaries = function () {
}
};
+// Peer to peer primitives
+
+Process.prototype.sendPeerMessage = function (message, peer) {
+ var myself = this;
+
+ if (peer instanceof List) {
+ peer.asArray().forEach(function (singlePeer) {
+ myself.sendPeerMessage(message, singlePeer);
+ });
+ return;
+ }
+
+ var stage = this.homeContext.receiver.parentThatIsA(StageMorph),
+ ide = this.homeContext.receiver.parentThatIsA(IDE_Morph);
+ var connection = stage.peer.connect(peer, {reliable: true});
+ connection.on('open', function () {
+ var data;
+ if (typeof message == "string") {
+ data = message;
+ } else if (typeof message == "function") {
+ data = message.toString();
+ } else {
+ data = ide.serializer.serialize(message);
+ }
+ connection.send(data);
+ });
+};
+
+Process.prototype.reportPeerList = function () {
+ var myself = this;
+
+ if (!this.context.wait) {
+ var stage = this.homeContext.receiver.parentThatIsA(StageMorph);
+ stage.peer.listAllPeers(function (peers) {
+ myself.context.result = new List(peers);
+ });
+ this.context.wait = true;
+ } else if (this.context.result) {
+ return this.context.result;
+ }
+
+ this.pushContext('doYield');
+ this.pushContext();
+};
+
+Process.prototype.reportPeerId = function () {
+ var stage = this.homeContext.receiver.parentThatIsA(StageMorph);
+ return stage.peerId;
+};
+
// Process lists primitives
Process.prototype.reportNewList = function (elements) {
@@ -1969,7 +2019,7 @@ Process.prototype.reportTypeOf = function (thing) {
if (thing === true || (thing === false)) {
return 'Boolean';
}
- if (!isNaN(filterFloat(thing))) {
+ if (!isNaN(+thing)) {
return 'number';
}
if (isString(thing)) {