mirror of
https://github.com/schlagmichdoch/PairDrop.git
synced 2025-04-20 07:05:05 -04:00
Network fixes
This commit is contained in:
parent
10196cdf33
commit
23e7c04393
5 changed files with 46 additions and 55 deletions
|
@ -34,12 +34,14 @@ class SnapdropServer {
|
|||
switch (message.type) {
|
||||
case 'disconnect':
|
||||
this._leaveRoom(sender);
|
||||
break;
|
||||
case 'pong':
|
||||
sender.lastBeat = Date.now();
|
||||
break;
|
||||
}
|
||||
|
||||
// relay message to recipient
|
||||
if (message.to) {
|
||||
if (message.to && this._rooms[sender.ip]) {
|
||||
const recipientId = message.to; // TODO: sanitize
|
||||
const recipient = this._rooms[sender.ip][recipientId];
|
||||
delete message.to;
|
||||
|
@ -84,7 +86,7 @@ class SnapdropServer {
|
|||
_leaveRoom(peer) {
|
||||
// delete the peer
|
||||
this._cancelKeepAlive(peer);
|
||||
if (!this._rooms[peer.ip]) return;
|
||||
if (!this._rooms[peer.ip] || !this._rooms[peer.ip][peer.id]) return;
|
||||
|
||||
delete this._rooms[peer.ip][peer.id];
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue