@oox/socketio-client 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/browser.js +14 -8
- package/browser.js.map +1 -1
- package/package.json +1 -1
package/adapter.js
CHANGED
|
@@ -12,7 +12,7 @@ export class SocketIOAdapter extends SampleKeepAliveConnectionAdapter {
|
|
|
12
12
|
'x-caller': name,
|
|
13
13
|
'x-caller-id': id,
|
|
14
14
|
};
|
|
15
|
-
let mURL;
|
|
15
|
+
let mURL = undefined;
|
|
16
16
|
const connectionData = {
|
|
17
17
|
name: 'anonymous',
|
|
18
18
|
id: String(++this.connectionId),
|
|
@@ -29,12 +29,17 @@ export class SocketIOAdapter extends SampleKeepAliveConnectionAdapter {
|
|
|
29
29
|
else if (identify.url) {
|
|
30
30
|
// KeepAliveConnectionData
|
|
31
31
|
Object.assign(connectionData, identify);
|
|
32
|
-
|
|
32
|
+
if ('string' === typeof identify.url) {
|
|
33
|
+
mURL = genWebSocketURL(identify.url);
|
|
34
|
+
}
|
|
35
|
+
else if (identify.url instanceof URL) {
|
|
36
|
+
mURL = identify.url;
|
|
37
|
+
}
|
|
33
38
|
if (identify.token) {
|
|
34
39
|
headers['x-token'] = identify.token;
|
|
35
40
|
}
|
|
36
41
|
}
|
|
37
|
-
|
|
42
|
+
if (!mURL) {
|
|
38
43
|
throw new Error('identify must be string, URL, or KeepAliveConnectionData');
|
|
39
44
|
}
|
|
40
45
|
const socket = io(mURL.origin, {
|
package/browser.js
CHANGED
|
@@ -990,8 +990,8 @@ var OOXSocketIOClient = (function (exports, oox) {
|
|
|
990
990
|
/**
|
|
991
991
|
* Sends data.
|
|
992
992
|
*
|
|
993
|
-
* @param {String} data to send.
|
|
994
|
-
* @param {Function} called upon flush.
|
|
993
|
+
* @param {String} data - data to send.
|
|
994
|
+
* @param {Function} fn - called upon flush.
|
|
995
995
|
* @private
|
|
996
996
|
*/
|
|
997
997
|
doWrite(data, fn) {
|
|
@@ -1904,7 +1904,7 @@ var OOXSocketIOClient = (function (exports, oox) {
|
|
|
1904
1904
|
/**
|
|
1905
1905
|
* Sends a packet.
|
|
1906
1906
|
*
|
|
1907
|
-
* @param {String} type
|
|
1907
|
+
* @param {String} type - packet type.
|
|
1908
1908
|
* @param {String} data.
|
|
1909
1909
|
* @param {Object} options.
|
|
1910
1910
|
* @param {Function} fn - callback function.
|
|
@@ -2210,14 +2210,15 @@ var OOXSocketIOClient = (function (exports, oox) {
|
|
|
2210
2210
|
*/
|
|
2211
2211
|
let Socket$1 = class Socket extends SocketWithUpgrade {
|
|
2212
2212
|
constructor(uri, opts = {}) {
|
|
2213
|
-
const
|
|
2213
|
+
const isOptionsOnly = typeof uri === "object";
|
|
2214
|
+
const o = isOptionsOnly ? { ...uri } : { ...opts };
|
|
2214
2215
|
if (!o.transports ||
|
|
2215
2216
|
(o.transports && typeof o.transports[0] === "string")) {
|
|
2216
2217
|
o.transports = (o.transports || ["polling", "websocket", "webtransport"])
|
|
2217
2218
|
.map((transportName) => transports[transportName])
|
|
2218
2219
|
.filter((t) => !!t);
|
|
2219
2220
|
}
|
|
2220
|
-
super(uri, o);
|
|
2221
|
+
super(isOptionsOnly ? o : uri, o);
|
|
2221
2222
|
}
|
|
2222
2223
|
};
|
|
2223
2224
|
|
|
@@ -4104,7 +4105,7 @@ var OOXSocketIOClient = (function (exports, oox) {
|
|
|
4104
4105
|
'x-caller': name,
|
|
4105
4106
|
'x-caller-id': id,
|
|
4106
4107
|
};
|
|
4107
|
-
let mURL;
|
|
4108
|
+
let mURL = undefined;
|
|
4108
4109
|
const connectionData = {
|
|
4109
4110
|
name: 'anonymous',
|
|
4110
4111
|
id: String(++this.connectionId),
|
|
@@ -4121,12 +4122,17 @@ var OOXSocketIOClient = (function (exports, oox) {
|
|
|
4121
4122
|
else if (identify.url) {
|
|
4122
4123
|
// KeepAliveConnectionData
|
|
4123
4124
|
Object.assign(connectionData, identify);
|
|
4124
|
-
|
|
4125
|
+
if ('string' === typeof identify.url) {
|
|
4126
|
+
mURL = genWebSocketURL(identify.url);
|
|
4127
|
+
}
|
|
4128
|
+
else if (identify.url instanceof URL) {
|
|
4129
|
+
mURL = identify.url;
|
|
4130
|
+
}
|
|
4125
4131
|
if (identify.token) {
|
|
4126
4132
|
headers['x-token'] = identify.token;
|
|
4127
4133
|
}
|
|
4128
4134
|
}
|
|
4129
|
-
|
|
4135
|
+
if (!mURL) {
|
|
4130
4136
|
throw new Error('identify must be string, URL, or KeepAliveConnectionData');
|
|
4131
4137
|
}
|
|
4132
4138
|
const socket = lookup(mURL.origin, {
|