Decrease redundancy by changing the way the websocket fallback is included; Adding new env var SIGNALING_SERVER to host client files but use another server for signaling.

This commit is contained in:
schlagmichdoch 2023-11-08 20:31:57 +01:00
parent cb72edef20
commit 3439e7f6d4
62 changed files with 439 additions and 10101 deletions

View file

@ -16,7 +16,6 @@ export default class PairDropWsServer {
this._wss = new WebSocketServer({ server });
this._wss.on('connection', (socket, request) => this._onConnection(new Peer(socket, request, conf)));
console.log('\nPairDrop is running on port', this._conf.port);
}
_onConnection(peer) {
@ -26,8 +25,11 @@ export default class PairDropWsServer {
this._keepAlive(peer);
this._send(peer, {
type: 'rtc-config',
config: this._conf.rtcConfig
type: 'ws-config',
wsConfig: {
rtcConfig: this._conf.rtcConfig,
wsFallback: this._conf.wsFallback
}
});
// send displayName
@ -87,8 +89,26 @@ export default class PairDropWsServer {
this._onLeavePublicRoom(sender);
break;
case 'signal':
default:
this._signalAndRelay(sender, message);
break;
case 'request':
case 'header':
case 'partition':
case 'partition-received':
case 'progress':
case 'files-transfer-response':
case 'file-transfer-complete':
case 'message-transfer-complete':
case 'text':
case 'display-name-changed':
case 'ws-chunk':
// relay ws-fallback
if (this._conf.wsFallback) {
this._signalAndRelay(sender, message);
}
else {
console.log("Websocket fallback is not activated on this instance.")
}
}
}