Keep connections alive

This commit is contained in:
Robin Linus 2015-12-31 00:42:53 +01:00
parent 3b4784e8eb
commit 00aa38564c
2 changed files with 80 additions and 94 deletions

View file

@ -23,7 +23,6 @@
}.bind(this);
},
initialize: function() {
if (window.isActive) {
clearInterval(this.reconnectTimer);
this.reconnectTimer = undefined;
var options;
@ -65,7 +64,6 @@
return;
}
}.bind(this));
}
},
connect: function(c) {

View file

@ -9,23 +9,12 @@
</template>
<script>
'use strict';
window.isActive = true;
window.onfocus = function() {
window.isActive = true;
};
window.onblur = function() {
window.isActive = false;
};
Polymer({
is: 'web-socket',
attached: function() {
this.init();
},
init: function() {
if (window.isActive) {
clearInterval(this.reconnectTimer);
this.reconnectTimer = undefined;
var websocketUrl = (window.debug ? 'ws://' + window.location.hostname + ':3002' : 'wss://snapdrop.net') + '/binary';
@ -70,7 +59,6 @@
this.client.on('close', function(e) {
this._reconnect(e);
}.bind(this));
}
},
_sendFile: function(toPeer, file) {
console.log('send file via WebSocket', file);