configurapi-runner-ws 1.11.0 → 1.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/index.js +14 -5
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -58,7 +58,7 @@ module.exports = class HttpRunner extends events.EventEmitter
|
|
|
58
58
|
e.response.body = Object.keys(connections);
|
|
59
59
|
});
|
|
60
60
|
loader.handlers.set('post_@connection', async (e)=>
|
|
61
|
-
{
|
|
61
|
+
{
|
|
62
62
|
e.response.headers['Content-Type'] = 'application/json';
|
|
63
63
|
|
|
64
64
|
const connectionId = e.params?.['@connection'];
|
|
@@ -142,12 +142,17 @@ module.exports = class HttpRunner extends events.EventEmitter
|
|
|
142
142
|
}
|
|
143
143
|
this.emit("trace", `[connect] ${connectionId}`);
|
|
144
144
|
|
|
145
|
-
|
|
146
|
-
|
|
145
|
+
if (config.events.has('on_connect'))
|
|
146
|
+
{
|
|
147
|
+
const response = await this._requestListener(ws, undefined, 'on_connect');
|
|
148
|
+
|
|
149
|
+
if (response.statusCode >= 400)
|
|
150
|
+
{
|
|
151
|
+
return ws.close(1008, 'Policy Violation');
|
|
152
|
+
}
|
|
153
|
+
}
|
|
147
154
|
ws.on("message", async (data) =>
|
|
148
155
|
{
|
|
149
|
-
await onConnectPromise;
|
|
150
|
-
|
|
151
156
|
const incomingMessage = typeof data === "string" ? data : data.toString("utf8");
|
|
152
157
|
|
|
153
158
|
await this._requestListener(ws, incomingMessage);
|
|
@@ -225,6 +230,8 @@ module.exports = class HttpRunner extends events.EventEmitter
|
|
|
225
230
|
|
|
226
231
|
await WsAdapter.write(ws, event.response); // Send response back to the caller.
|
|
227
232
|
}
|
|
233
|
+
|
|
234
|
+
return event.response;
|
|
228
235
|
}
|
|
229
236
|
catch (error)
|
|
230
237
|
{
|
|
@@ -251,6 +258,8 @@ module.exports = class HttpRunner extends events.EventEmitter
|
|
|
251
258
|
console.log(errorFromListner);
|
|
252
259
|
}
|
|
253
260
|
}
|
|
261
|
+
|
|
262
|
+
return response;
|
|
254
263
|
}
|
|
255
264
|
}
|
|
256
265
|
|