Squashed commit of the following:

commit 5b7ac6f0f56f3888c01049f08b6b47dbeb3bcfb0
Author: Robin Linus <robin_woll@capira.de>
Date:   Wed Dec 30 18:06:48 2015 +0100

    Clean up about and social links

commit 9c7da37d1e8f58f1c45626289fbab336fc982a0f
Author: Robin Linus <robin_woll@capira.de>
Date:   Wed Dec 30 18:06:35 2015 +0100

    Change Slogan

commit fcea5cfb5c6928acabce44caacc1d75fafdab447
Author: Robin Linus <robin_woll@capira.de>
Date:   Wed Dec 30 18:06:22 2015 +0100

    Add shorturl

commit f09e9e42c30aa7b26df2a5fb00bec653f3ad68e1
Author: Robin Linus <robin_woll@capira.de>
Date:   Wed Dec 30 16:56:55 2015 +0100

    initial
This commit is contained in:
Robin Linus 2015-12-30 18:07:37 +01:00
parent 1bce467a7c
commit e756a3fd0c
11 changed files with 278 additions and 128 deletions

View file

@ -23,47 +23,49 @@
}.bind(this);
},
initialize: function() {
var options;
if (window.debug) {
options = {
host: window.location.hostname,
port: 3002,
path: 'peerjs'
};
} else {
options = {
host: 'snapdrop.net',
port: 443,
path: 'peerjs',
secure: true
};
}
this._peer = new Peer(this.me, options);
this._peer.on('open', function(id) {
console.log('My peer ID is: ' + id);
this.set('me', id);
this._peerOpen = true;
this._initCallbacks.forEach(function(cb) {
cb();
});
}.bind(this));
if (window.isActive) {
clearInterval(this.reconnectTimer);
this.reconnectTimer = undefined;
var options;
if (window.debug) {
options = {
host: window.location.hostname,
port: 3002,
path: 'peerjs'
};
} else {
options = {
host: 'snapdrop.net',
port: 443,
path: 'peerjs',
secure: true
};
}
this._peer = new Peer(this.me, options);
this._peer.on('open', function(id) {
console.log('My peer ID is: ' + id);
this.set('me', id);
this._peerOpen = true;
this._initCallbacks.forEach(function(cb) {
cb();
});
}.bind(this));
this._peer.on('connection', this.connect.bind(this));
this._peer.on('error', function(err) {
console.error(err);
//ugly hack to find out error type
if (err.message.indexOf('Could not connect to peer') > -1) {
delete this._connectedPeers[this.peer];
this.set('peer', 'error');
return;
}
if (err.message.indexOf('Lost connection to server') > -1) {
this._peer.destroy();
this.set('me', this.me);
this.async(this._initialize, 3000);
return;
}
}.bind(this));
this._peer.on('connection', this.connect.bind(this));
this._peer.on('error', function(err) {
console.error(err);
//ugly hack to find out error type
if (err.message.indexOf('Could not connect to peer') > -1) {
delete this._connectedPeers[this.peer];
return;
}
if (err.message.indexOf('Lost connection to server') > -1) {
this._peer.destroy();
this._reconnect();
return;
}
}.bind(this));
}
},
connect: function(c) {
@ -145,7 +147,7 @@
conns.forEach(function(conn) {
if (conn.label === 'file') {
conn.send(file);
console.log('file send via WebRTC');
console.log('send file via WebRTC');
}
}.bind(this));
}
@ -159,6 +161,12 @@
}
}.bind(this));
}
},
_reconnect: function(e) {
//try to reconnect after 3s
if (!this.reconnectTimer) {
this.reconnectTimer = setInterval(this.initialize.bind(this), 3000);
}
}
});
</script>