mirror of
https://github.com/schlagmichdoch/PairDrop.git
synced 2025-04-20 15:06:15 -04:00
Keep connections alive
This commit is contained in:
parent
3b4784e8eb
commit
00aa38564c
2 changed files with 80 additions and 94 deletions
|
@ -23,7 +23,6 @@
|
||||||
}.bind(this);
|
}.bind(this);
|
||||||
},
|
},
|
||||||
initialize: function() {
|
initialize: function() {
|
||||||
if (window.isActive) {
|
|
||||||
clearInterval(this.reconnectTimer);
|
clearInterval(this.reconnectTimer);
|
||||||
this.reconnectTimer = undefined;
|
this.reconnectTimer = undefined;
|
||||||
var options;
|
var options;
|
||||||
|
@ -65,7 +64,6 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
connect: function(c) {
|
connect: function(c) {
|
||||||
|
|
|
@ -9,23 +9,12 @@
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
'use strict';
|
'use strict';
|
||||||
window.isActive = true;
|
|
||||||
|
|
||||||
window.onfocus = function() {
|
|
||||||
window.isActive = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
window.onblur = function() {
|
|
||||||
window.isActive = false;
|
|
||||||
};
|
|
||||||
|
|
||||||
Polymer({
|
Polymer({
|
||||||
is: 'web-socket',
|
is: 'web-socket',
|
||||||
attached: function() {
|
attached: function() {
|
||||||
this.init();
|
this.init();
|
||||||
},
|
},
|
||||||
init: function() {
|
init: function() {
|
||||||
if (window.isActive) {
|
|
||||||
clearInterval(this.reconnectTimer);
|
clearInterval(this.reconnectTimer);
|
||||||
this.reconnectTimer = undefined;
|
this.reconnectTimer = undefined;
|
||||||
var websocketUrl = (window.debug ? 'ws://' + window.location.hostname + ':3002' : 'wss://snapdrop.net') + '/binary';
|
var websocketUrl = (window.debug ? 'ws://' + window.location.hostname + ':3002' : 'wss://snapdrop.net') + '/binary';
|
||||||
|
@ -70,7 +59,6 @@
|
||||||
this.client.on('close', function(e) {
|
this.client.on('close', function(e) {
|
||||||
this._reconnect(e);
|
this._reconnect(e);
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
}
|
|
||||||
},
|
},
|
||||||
_sendFile: function(toPeer, file) {
|
_sendFile: function(toPeer, file) {
|
||||||
console.log('send file via WebSocket', file);
|
console.log('send file via WebSocket', file);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue