mirror of
https://github.com/schlagmichdoch/PairDrop.git
synced 2025-04-20 15:06:15 -04:00
only reopen connection if it exists
This commit is contained in:
parent
7b84154e3f
commit
8b8c887458
1 changed files with 4 additions and 4 deletions
|
@ -194,12 +194,12 @@ class Peer {
|
||||||
|
|
||||||
_onChunkReceived(chunk) {
|
_onChunkReceived(chunk) {
|
||||||
if(!chunk.byteLength) return;
|
if(!chunk.byteLength) return;
|
||||||
|
|
||||||
this._digester.unchunk(chunk);
|
this._digester.unchunk(chunk);
|
||||||
const progress = this._digester.progress;
|
const progress = this._digester.progress;
|
||||||
this._onDownloadProgress(progress);
|
this._onDownloadProgress(progress);
|
||||||
|
|
||||||
// occasionally notify sender about our progress
|
// occasionally notify sender about our progress
|
||||||
if (progress - this._lastProgress < 0.01) return;
|
if (progress - this._lastProgress < 0.01) return;
|
||||||
this._lastProgress = progress;
|
this._lastProgress = progress;
|
||||||
this._sendProgress(progress);
|
this._sendProgress(progress);
|
||||||
|
@ -261,7 +261,7 @@ class RTCPeer extends Peer {
|
||||||
}
|
}
|
||||||
|
|
||||||
_openChannel() {
|
_openChannel() {
|
||||||
const channel = this._conn.createDataChannel('data-channel', {
|
const channel = this._conn.createDataChannel('data-channel', {
|
||||||
ordered: true,
|
ordered: true,
|
||||||
reliable: true // Obsolete. See https://developer.mozilla.org/en-US/docs/Web/API/RTCDataChannel/reliable
|
reliable: true // Obsolete. See https://developer.mozilla.org/en-US/docs/Web/API/RTCDataChannel/reliable
|
||||||
});
|
});
|
||||||
|
@ -309,7 +309,7 @@ class RTCPeer extends Peer {
|
||||||
|
|
||||||
_onChannelClosed() {
|
_onChannelClosed() {
|
||||||
console.log('RTC: channel closed', this._peerId);
|
console.log('RTC: channel closed', this._peerId);
|
||||||
if (!this._isCaller) return;
|
if (!this._isCaller || !this._conn) return;
|
||||||
this._connect(this._peerId, true); // reopen the channel
|
this._connect(this._peerId, true); // reopen the channel
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue