summaryrefslogtreecommitdiff
path: root/objects.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 /objects.js
parentbdd780e0030507626c947f85880a9eaa36e24194 (diff)
parent121cf8b3658909f79571b621e9a9916c7f601dfc (diff)
downloadsnap-315e01b93ae3f200cea44b086936e3d4d9ab7fc7.tar.gz
snap-315e01b93ae3f200cea44b086936e3d4d9ab7fc7.zip
merge branch p2p
Diffstat (limited to 'objects.js')
-rw-r--r--objects.js46
1 files changed, 1 insertions, 45 deletions
diff --git a/objects.js b/objects.js
index a893cee..18825dc 100644
--- a/objects.js
+++ b/objects.js
@@ -4754,55 +4754,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;
-
- if (window.peers) {
- // I don't know why, but it works.
- window.peers.forEach(function (oldpeer) {
- if (id != oldpeer.id) {
- oldpeer.destroy()
- }
- });
- }
-
- this.peer = new Peer(id, {
- host: 'snapmesh.herokuapp.com',
- port: 443,
- secure: true,
- path: '/'
- });
-
- this.peer.on('open', function (id) {
- myself.peerId = id;
- });
- this.peer.on('disconnected', function () {
- // peer.reconnect does not work (?) because 'id' is undefined
- if (!myself.peer.destroyed) {
- myself.initPeering(myself.peerId);
- }
- });
- 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);
- });
- });
- });
-
- window.peers.push(this.peer);
};
StageMorph.prototype.newPeerMessage = function (data, peer) {
var ide = this.parentThatIsA(IDE_Morph);
+ if (!ide || !peer) return;
var myself = this;
var hats = [], model, message;