build
This commit is contained in:
parent
a77de706c7
commit
355dc574f8
11
dist/src/instance.js
vendored
11
dist/src/instance.js
vendored
@ -27,12 +27,13 @@ const createInstance = ({ app, server, options }) => {
|
|||||||
app.use(options.path, api);
|
app.use(options.path, api);
|
||||||
//use mountpath for WS server
|
//use mountpath for WS server
|
||||||
const customConfig = Object.assign(Object.assign({}, config), { path: path_1.default.posix.join(app.path(), options.path, '/') });
|
const customConfig = Object.assign(Object.assign({}, config), { path: path_1.default.posix.join(app.path(), options.path, '/') });
|
||||||
const wss2 = new webSocketServer_1.WebSocketServer({
|
const wss = new webSocketServer_1.WebSocketServer({
|
||||||
server,
|
server,
|
||||||
realm,
|
realm,
|
||||||
config: customConfig
|
config: customConfig
|
||||||
});
|
});
|
||||||
wss2.on("connection", (client) => {
|
app.set('peerWs', wss);
|
||||||
|
wss.on("connection", (client) => {
|
||||||
const messageQueue = realm.getMessageQueueById(client.getId());
|
const messageQueue = realm.getMessageQueueById(client.getId());
|
||||||
if (messageQueue) {
|
if (messageQueue) {
|
||||||
let message;
|
let message;
|
||||||
@ -43,14 +44,14 @@ const createInstance = ({ app, server, options }) => {
|
|||||||
}
|
}
|
||||||
app.emit("connection", client);
|
app.emit("connection", client);
|
||||||
});
|
});
|
||||||
wss2.on("message", (client, message) => {
|
wss.on("message", (client, message) => {
|
||||||
app.emit("message", client, message);
|
app.emit("message", client, message);
|
||||||
messageHandler.handle(client, message);
|
messageHandler.handle(client, message);
|
||||||
});
|
});
|
||||||
wss2.on("close", (client) => {
|
wss.on("close", (client) => {
|
||||||
app.emit("disconnect", client);
|
app.emit("disconnect", client);
|
||||||
});
|
});
|
||||||
wss2.on("error", (error) => {
|
wss.on("error", (error) => {
|
||||||
app.emit("error", error);
|
app.emit("error", error);
|
||||||
});
|
});
|
||||||
messagesExpire.startMessagesExpiration();
|
messagesExpire.startMessagesExpiration();
|
||||||
|
2
dist/src/services/webSocketServer/index.js
vendored
2
dist/src/services/webSocketServer/index.js
vendored
@ -18,7 +18,7 @@ class WebSocketServer extends events_1.default {
|
|||||||
this.config = config;
|
this.config = config;
|
||||||
const path = this.config.path;
|
const path = this.config.path;
|
||||||
this.path = `${path}${path.endsWith('/') ? "" : "/"}${WS_PATH}`;
|
this.path = `${path}${path.endsWith('/') ? "" : "/"}${WS_PATH}`;
|
||||||
this.socketServer = new ws_1.default.Server({ path: this.path, server });
|
this.socketServer = new ws_1.default.Server(Object.assign({ path: this.path, server }, this.config.ws));
|
||||||
this.socketServer.on("connection", (socket, req) => this._onSocketConnection(socket, req));
|
this.socketServer.on("connection", (socket, req) => this._onSocketConnection(socket, req));
|
||||||
this.socketServer.on("error", (error) => this._onSocketError(error));
|
this.socketServer.on("error", (error) => this._onSocketError(error));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user