mirror of
https://github.com/schlagmichdoch/PairDrop.git
synced 2025-04-21 07:16:18 -04:00
ensure that otherPeers never receive peer-left
after peer-joined
on reconnect by leaving room before rejoining it
This commit is contained in:
parent
f195c686e7
commit
26bf4d6dc3
1 changed files with 5 additions and 0 deletions
5
index.js
5
index.js
|
@ -362,6 +362,11 @@ class PairDropServer {
|
||||||
_joinRoom(peer, roomType = 'ip', roomSecret = '') {
|
_joinRoom(peer, roomType = 'ip', roomSecret = '') {
|
||||||
const room = roomType === 'ip' ? peer.ip : roomSecret;
|
const room = roomType === 'ip' ? peer.ip : roomSecret;
|
||||||
|
|
||||||
|
if (this._rooms[room] && this._rooms[room][peer.id]) {
|
||||||
|
// ensures that otherPeers never receive `peer-left` after `peer-joined` on reconnect.
|
||||||
|
this._leaveRoom(peer, roomType, roomSecret);
|
||||||
|
}
|
||||||
|
|
||||||
// if room doesn't exist, create it
|
// if room doesn't exist, create it
|
||||||
if (!this._rooms[room]) {
|
if (!this._rooms[room]) {
|
||||||
this._rooms[room] = {};
|
this._rooms[room] = {};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue