configurapi-runner-ws 1.7.0 → 1.9.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 +8 -6
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -79,18 +79,20 @@ module.exports = class HttpRunner extends events.EventEmitter
|
|
|
79
79
|
|
|
80
80
|
this.emit("trace", `[connect] ${connectionId}`);
|
|
81
81
|
|
|
82
|
-
this._requestListener(ws, undefined, 'on_connect');
|
|
82
|
+
let onConnectPromise = this._requestListener(ws, undefined, 'on_connect');
|
|
83
83
|
|
|
84
84
|
ws.on("message", async (data) =>
|
|
85
85
|
{
|
|
86
|
+
await onConnectPromise;
|
|
87
|
+
|
|
86
88
|
const incomingMessage = typeof data === "string" ? data : data.toString("utf8");
|
|
87
89
|
|
|
88
|
-
this._requestListener(ws, incomingMessage);
|
|
90
|
+
await this._requestListener(ws, incomingMessage);
|
|
89
91
|
});
|
|
90
92
|
|
|
91
|
-
ws.on("close", (code, reason) =>
|
|
93
|
+
ws.on("close", async(code, reason) =>
|
|
92
94
|
{
|
|
93
|
-
this._requestListener(ws, undefined, 'on_disconnect');
|
|
95
|
+
await this._requestListener(ws, undefined, 'on_disconnect');
|
|
94
96
|
|
|
95
97
|
const reasonMessage = reason && reason.length ? reason.toString("utf8") : "";
|
|
96
98
|
|
|
@@ -125,7 +127,7 @@ module.exports = class HttpRunner extends events.EventEmitter
|
|
|
125
127
|
try
|
|
126
128
|
{
|
|
127
129
|
event = new Configurapi.Event(await WsAdapter.toRequest(ws, incomingMessage));
|
|
128
|
-
|
|
130
|
+
|
|
129
131
|
if(customEventName)
|
|
130
132
|
{
|
|
131
133
|
event.name = customEventName;
|
|
@@ -142,7 +144,7 @@ module.exports = class HttpRunner extends events.EventEmitter
|
|
|
142
144
|
|
|
143
145
|
event.response.headers['Sec-WebSocket-Protocol'] = protocol;
|
|
144
146
|
}
|
|
145
|
-
|
|
147
|
+
|
|
146
148
|
await WsAdapter.write(ws, event.response);
|
|
147
149
|
}
|
|
148
150
|
else
|