mirror of
https://github.com/schlagmichdoch/PairDrop.git
synced 2025-04-20 15:06:15 -04:00
fix error Cannot set remote answer in state stable
This commit is contained in:
parent
19d7e6fecd
commit
ec6bee05fd
1 changed files with 12 additions and 21 deletions
|
@ -264,12 +264,12 @@ class Peer {
|
||||||
combinedSize += files[i].size;
|
combinedSize += files[i].size;
|
||||||
}
|
}
|
||||||
this._fileHeaderRequested = header;
|
this._fileHeaderRequested = header;
|
||||||
let bytesCompleted = 0;
|
|
||||||
|
|
||||||
|
let bytesCompleted = 0;
|
||||||
zipper.createNewZipWriter();
|
zipper.createNewZipWriter();
|
||||||
for (let i=0; i<files.length; i++) {
|
for (let i=0; i<files.length; i++) {
|
||||||
const entry = await zipper.addFile(files[i], {
|
await zipper.addFile(files[i], {
|
||||||
onprogress: (progress, total) => {
|
onprogress: (progress) => {
|
||||||
Events.fire('set-progress', {
|
Events.fire('set-progress', {
|
||||||
peerId: this._peerId,
|
peerId: this._peerId,
|
||||||
progress: (bytesCompleted + progress) / combinedSize,
|
progress: (bytesCompleted + progress) / combinedSize,
|
||||||
|
@ -543,7 +543,7 @@ class RTCPeer extends Peer {
|
||||||
if (!this._conn) this._connect(message.sender, false);
|
if (!this._conn) this._connect(message.sender, false);
|
||||||
|
|
||||||
if (message.sdp) {
|
if (message.sdp) {
|
||||||
this._conn.setRemoteDescription(new RTCSessionDescription(message.sdp))
|
this._conn.setRemoteDescription(message.sdp)
|
||||||
.then( _ => {
|
.then( _ => {
|
||||||
if (message.sdp.type === 'offer') {
|
if (message.sdp.type === 'offer') {
|
||||||
return this._conn.createAnswer()
|
return this._conn.createAnswer()
|
||||||
|
@ -663,29 +663,20 @@ class PeersManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
_onMessage(message) {
|
_onMessage(message) {
|
||||||
this._refreshOrCreatePeer(message.sender, message.roomType, message.roomSecret);
|
// if different roomType -> abort
|
||||||
|
if (this.peers[message.sender] && this.peers[message.sender]._roomType !== message.roomType) return;
|
||||||
|
if (!this.peers[message.sender]) {
|
||||||
|
this.peers[message.sender] = new RTCPeer(this._server, undefined, message.roomType, message.roomSecret);
|
||||||
|
}
|
||||||
this.peers[message.sender].onServerMessage(message);
|
this.peers[message.sender].onServerMessage(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
_refreshOrCreatePeer(id, roomType, roomSecret) {
|
|
||||||
if (!this.peers[id]) {
|
|
||||||
this.peers[id] = new RTCPeer(this._server, undefined, roomType, roomSecret);
|
|
||||||
}else if (this.peers[id]._roomType !== roomType) {
|
|
||||||
this.peers[id]._roomType = roomType;
|
|
||||||
this.peers[id]._roomSecret = roomSecret;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_onPeers(msg) {
|
_onPeers(msg) {
|
||||||
msg.peers.forEach(peer => {
|
msg.peers.forEach(peer => {
|
||||||
if (this.peers[peer.id]) {
|
if (this.peers[peer.id]) {
|
||||||
if (this.peers[peer.id].roomType === msg.roomType) {
|
// if different roomType -> abort
|
||||||
|
if (this.peers[peer.id].roomType !== msg.roomType) return;
|
||||||
this.peers[peer.id].refresh();
|
this.peers[peer.id].refresh();
|
||||||
} else {
|
|
||||||
this.peers[peer.id].roomType = msg.roomType;
|
|
||||||
this.peers[peer.id].roomSecret = msg.roomSecret;
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
if (window.isRtcSupported && peer.rtcSupported) {
|
if (window.isRtcSupported && peer.rtcSupported) {
|
||||||
this.peers[peer.id] = new RTCPeer(this._server, peer.id, msg.roomType, msg.roomSecret);
|
this.peers[peer.id] = new RTCPeer(this._server, peer.id, msg.roomType, msg.roomSecret);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue