|
@@ -18,7 +18,7 @@ interface IAuthParams {
|
|
|
key?: string;
|
|
|
}
|
|
|
|
|
|
-type CustomConfig = Pick<IConfig, 'path' | 'key' | 'concurrent_limit' | 'ws'>;
|
|
|
+type CustomConfig = Pick<IConfig, 'path' | 'key' | 'concurrent_limit' | 'createWebSocketServer'>;
|
|
|
|
|
|
const WS_PATH = 'peerjs';
|
|
|
|
|
@@ -40,11 +40,16 @@ export class WebSocketServer extends EventEmitter implements IWebSocketServer {
|
|
|
const path = this.config.path;
|
|
|
this.path = `${path}${path.endsWith('/') ? "" : "/"}${WS_PATH}`;
|
|
|
|
|
|
- this.socketServer = new WebSocketLib.Server({
|
|
|
+ const options = {
|
|
|
path: this.path,
|
|
|
server,
|
|
|
- ...this.config.ws,
|
|
|
- });
|
|
|
+ };
|
|
|
+
|
|
|
+ this.socketServer = (
|
|
|
+ config.createWebSocketServer ?
|
|
|
+ config.createWebSocketServer(options) :
|
|
|
+ new WebSocketLib.Server(options)
|
|
|
+ );
|
|
|
|
|
|
this.socketServer.on("connection", (socket: MyWebSocket, req) => this._onSocketConnection(socket, req));
|
|
|
this.socketServer.on("error", (error: Error) => this._onSocketError(error));
|