summaryrefslogtreecommitdiff
path: root/gui.js
diff options
context:
space:
mode:
authorCode WvS <code-wvs@quantentunnel.de>2015-03-20 20:54:17 +0100
committerCode WvS <code-wvs@quantentunnel.de>2015-03-20 20:54:17 +0100
commit4fb62473dff7618bc340ff6825ca9663eea0a42a (patch)
treea2163fdd93a3a587c93c698277f1f9de590c274d /gui.js
parent4f8b0e5b8c72a951aa7f240eee8fc266ee03cac5 (diff)
parent121cf8b3658909f79571b621e9a9916c7f601dfc (diff)
downloadsnap-yow-4fb62473dff7618bc340ff6825ca9663eea0a42a.tar.gz
snap-yow-4fb62473dff7618bc340ff6825ca9663eea0a42a.zip
Merge branch 'p2p' of ../Snap--Build-Your-Own-Blocks into gh-pages
Diffstat (limited to 'gui.js')
-rw-r--r--gui.js31
1 files changed, 30 insertions, 1 deletions
diff --git a/gui.js b/gui.js
index ed01c23..e4fd6cd 100644
--- a/gui.js
+++ b/gui.js
@@ -263,7 +263,36 @@ IDE_Morph.prototype.init = function (isAutoFill) {
// override inherited properites:
this.color = this.backgroundColor;
- window.peers = [];
+ this.createPeer();
+};
+
+IDE_Morph.prototype.createPeer = function() {
+ var myself = this;
+ this.peer = new Peer(this.peerId, {
+ host: 'snapmesh.herokuapp.com',
+ port: 443,
+ secure: true,
+ path: '/'
+ });
+
+ this.peer.on('open', function (id) {
+ myself.peerId = id;
+ });
+ this.peer.on('disconnected', function () {
+ myself.peer.destroy();
+ myself.createPeer();
+ });
+ this.peer.on('error', function (err) {
+ console.log(err); // DEBUG
+ });
+
+ this.peer.on('connection', function (connection) {
+ connection.on('open', function () {
+ connection.on('data', function (data) {
+ myself.stage.newPeerMessage(data, connection.peer);
+ });
+ });
+ });
};
IDE_Morph.prototype.openIn = function (world) {