@oox/ws 1.0.0 → 1.0.2
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/adapter.js +8 -3
- package/package.json +1 -1
- package/server.js +1 -1
package/adapter.js
CHANGED
|
@@ -11,7 +11,7 @@ export default class WebSocketAdapter extends SampleKeepAliveConnectionAdapter {
|
|
|
11
11
|
'x-caller': name,
|
|
12
12
|
'x-caller-id': id,
|
|
13
13
|
};
|
|
14
|
-
let mURL;
|
|
14
|
+
let mURL = undefined;
|
|
15
15
|
const connectionData = {
|
|
16
16
|
name: 'anonymous',
|
|
17
17
|
id: randomUUID(),
|
|
@@ -28,12 +28,17 @@ export default class WebSocketAdapter extends SampleKeepAliveConnectionAdapter {
|
|
|
28
28
|
else if (identify.url) {
|
|
29
29
|
// KeepAliveConnectionData
|
|
30
30
|
Object.assign(connectionData, identify);
|
|
31
|
-
|
|
31
|
+
if ('string' === typeof identify.url) {
|
|
32
|
+
mURL = genWebSocketURL(identify.url);
|
|
33
|
+
}
|
|
34
|
+
else if (identify.url instanceof URL) {
|
|
35
|
+
mURL = identify.url;
|
|
36
|
+
}
|
|
32
37
|
if (identify.token) {
|
|
33
38
|
headers['x-token'] = identify.token;
|
|
34
39
|
}
|
|
35
40
|
}
|
|
36
|
-
|
|
41
|
+
if (!mURL) {
|
|
37
42
|
throw new Error('identify must be string, URL, or KeepAliveConnectionData');
|
|
38
43
|
}
|
|
39
44
|
const socket = new Socket(mURL, {
|
package/package.json
CHANGED
package/server.js
CHANGED
|
@@ -98,7 +98,6 @@ export default class WebSocketServer extends Module {
|
|
|
98
98
|
throw new Error('Cannot read ws server port');
|
|
99
99
|
this.config.port = address.port;
|
|
100
100
|
this.createWebSocketServer();
|
|
101
|
-
console.log(`WebSocketServer is running on port ${this.config.port}`);
|
|
102
101
|
}
|
|
103
102
|
async stop() {
|
|
104
103
|
const { server, socketServer } = this;
|
|
@@ -166,6 +165,7 @@ export default class WebSocketServer extends Module {
|
|
|
166
165
|
token,
|
|
167
166
|
});
|
|
168
167
|
oox.addKeepAliveConnection(connection);
|
|
168
|
+
connection.emit('connect');
|
|
169
169
|
this.bindServerConnectionEvents(connection);
|
|
170
170
|
socket.emit(OOXEvent.READY, {
|
|
171
171
|
id: oox.config.id,
|