summaryrefslogtreecommitdiff
path: root/gui.js
diff options
context:
space:
mode:
authorGubolin <gubolin@fantasymail.de>2015-03-24 18:30:47 +0100
committerGubolin <gubolin@fantasymail.de>2015-03-24 18:30:47 +0100
commit315e01b93ae3f200cea44b086936e3d4d9ab7fc7 (patch)
tree5e28d5536ffcff8aadd7490ef4ed4dfd2a002c50 /gui.js
parentbdd780e0030507626c947f85880a9eaa36e24194 (diff)
parent121cf8b3658909f79571b621e9a9916c7f601dfc (diff)
downloadsnap-315e01b93ae3f200cea44b086936e3d4d9ab7fc7.tar.gz
snap-315e01b93ae3f200cea44b086936e3d4d9ab7fc7.zip
merge branch p2p
Diffstat (limited to 'gui.js')
-rw-r--r--gui.js30
1 files changed, 30 insertions, 0 deletions
diff --git a/gui.js b/gui.js
index 79e9b02..56aa7bd 100644
--- a/gui.js
+++ b/gui.js
@@ -251,6 +251,36 @@ IDE_Morph.prototype.init = function (isAutoFill) {
setInterval(this.save, 1000 * 60 * 60 * 5); // every 5 minutes
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) {