diff options
| author | Gubolin <gubolin@fantasymail.de> | 2015-03-24 18:30:47 +0100 |
|---|---|---|
| committer | Gubolin <gubolin@fantasymail.de> | 2015-03-24 18:30:47 +0100 |
| commit | 315e01b93ae3f200cea44b086936e3d4d9ab7fc7 (patch) | |
| tree | 5e28d5536ffcff8aadd7490ef4ed4dfd2a002c50 /objects.js | |
| parent | bdd780e0030507626c947f85880a9eaa36e24194 (diff) | |
| parent | 121cf8b3658909f79571b621e9a9916c7f601dfc (diff) | |
| download | snap-315e01b93ae3f200cea44b086936e3d4d9ab7fc7.tar.gz snap-315e01b93ae3f200cea44b086936e3d4d9ab7fc7.zip | |
merge branch p2p
Diffstat (limited to 'objects.js')
| -rw-r--r-- | objects.js | 46 |
1 files changed, 1 insertions, 45 deletions
@@ -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; |
