summaryrefslogtreecommitdiff
path: root/objects.js
diff options
context:
space:
mode:
authorGubolin <gubolin@fantasymail.de>2015-03-20 20:53:20 +0100
committerGubolin <gubolin@fantasymail.de>2015-03-20 20:53:20 +0100
commit121cf8b3658909f79571b621e9a9916c7f601dfc (patch)
treeff2136892b76a278ecdb721894c628a08d66e9d9 /objects.js
parent9163b3ca714086e1877249bf38e47040bd1b3e67 (diff)
downloadsnap-p2p.tar.gz
snap-p2p.zip
create one peer per IDEp2p
Diffstat (limited to 'objects.js')
-rw-r--r--objects.js33
1 files changed, 1 insertions, 32 deletions
diff --git a/objects.js b/objects.js
index e25f119..3859295 100644
--- a/objects.js
+++ b/objects.js
@@ -4419,42 +4419,11 @@ StageMorph.prototype.init = function (globals) {
this.acceptsDrops = false;
this.setColor(new Color(255, 255, 255));
this.fps = this.frameRate;
-
- this.initPeering();
-};
-
-StageMorph.prototype.initPeering = function (id) {
- var myself = this;
-
- this.peer = new Peer(id, {
- host: 'snapmesh.herokuapp.com',
- port: 443,
- secure: true,
- path: '/'
- });
-
- this.peer.on('disconnected', function () {
- if (!myself.peer.destroyed && myself.peer.id) {
- myself.peer.reconnect();
- } else {
- myself.initPeering();
- }
- });
- 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.newPeerMessage(data, connection.peer);
- });
- });
- });
};
StageMorph.prototype.newPeerMessage = function (data, peer) {
var ide = this.parentThatIsA(IDE_Morph);
+ if (!ide || !peer) return;
var myself = this;
var hats = [], model, message;