This commit is contained in:
Sergii Kliuchnyk 2022-09-30 11:55:49 +03:00 committed by GitHub
parent 8695256271
commit 7deac0d07e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -36,15 +36,13 @@ export const createInstance = ({ app, server, options }: {
//use mountpath for WS server
const customConfig = { ...config, path: path.posix.join(app.path(), options.path, '/') };
const wss: IWebSocketServer = new WebSocketServer({
const wss2: IWebSocketServer = new WebSocketServer({
server,
realm,
config: customConfig
});
app.peerWs = wss;
wss.on("connection", (client: IClient) => {
wss2.on("connection", (client: IClient) => {
const messageQueue = realm.getMessageQueueById(client.getId());
if (messageQueue) {
@ -59,7 +57,7 @@ export const createInstance = ({ app, server, options }: {
app.emit("connection", client);
});
wss.on("message", (client: IClient, message: IMessage) => {
wss2.on("message", (client: IClient, message: IMessage) => {
app.emit("message", client, message);
messageHandler.handle(client, message);
});
@ -68,7 +66,7 @@ export const createInstance = ({ app, server, options }: {
app.emit("disconnect", client);
});
wss.on("error", (error: Error) => {
wss2.on("error", (error: Error) => {
app.emit("error", error);
});