@onyx-p/imlib-web 1.5.6 → 1.5.8
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/index.esm.js +37 -15
- package/index.umd.js +37 -15
- package/package.json +1 -1
package/index.esm.js
CHANGED
@@ -13305,6 +13305,7 @@ class WebSocketServer {
|
|
13305
13305
|
failedCount = 0;
|
13306
13306
|
reconnectTimer;
|
13307
13307
|
connectResolve;
|
13308
|
+
pendingMessages = [];
|
13308
13309
|
constructor(options) {
|
13309
13310
|
this.options = Object.assign(DefaultOptions, options);
|
13310
13311
|
}
|
@@ -13383,21 +13384,15 @@ class WebSocketServer {
|
|
13383
13384
|
};
|
13384
13385
|
}
|
13385
13386
|
const messageSeq = this.generateMessageSeq();
|
13386
|
-
|
13387
|
-
cmdId
|
13388
|
-
|
13389
|
-
|
13390
|
-
|
13391
|
-
|
13392
|
-
|
13393
|
-
|
13394
|
-
body: body,
|
13395
|
-
deviceType: 7
|
13396
|
-
};
|
13397
|
-
if (cmdId !== CmdIds$1.Heartbean) {
|
13398
|
-
logger.info(`websocket send -> cmd: 0x${cmdId.toString(16)}, messageSeq: ${messageSeq}`);
|
13387
|
+
if (this.isConnected) {
|
13388
|
+
this.doSendRawData(cmdId, body, messageSeq);
|
13389
|
+
} else {
|
13390
|
+
this.pendingMessages.push({
|
13391
|
+
cmdId,
|
13392
|
+
body,
|
13393
|
+
messageSeq
|
13394
|
+
});
|
13399
13395
|
}
|
13400
|
-
this.socket.send(buildWsPacketData(rpc_baseExports.NetworkRequest.encode(networkReq).finish()));
|
13401
13396
|
const respData = await new Promise(resolve => {
|
13402
13397
|
this.responseCallbacks.set(messageSeq, resolve);
|
13403
13398
|
setTimeout(() => {
|
@@ -13418,6 +13413,23 @@ class WebSocketServer {
|
|
13418
13413
|
data: respData
|
13419
13414
|
};
|
13420
13415
|
}
|
13416
|
+
doSendRawData(cmdId, body, messageSeq) {
|
13417
|
+
const networkReq = {
|
13418
|
+
cmdId: cmdId,
|
13419
|
+
messageSeq: Long.fromNumber(messageSeq),
|
13420
|
+
deviceId: Long.fromString(accountStore.user.deviceId),
|
13421
|
+
sessionId: Long.fromString(accountStore.user.sessionId),
|
13422
|
+
uid: Long.fromString(accountStore.user.uid),
|
13423
|
+
protocolVersion: SOCKET_PROTOCOL_VER,
|
13424
|
+
destId: '',
|
13425
|
+
body: body,
|
13426
|
+
deviceType: 7
|
13427
|
+
};
|
13428
|
+
if (cmdId !== CmdIds$1.Heartbean) {
|
13429
|
+
logger.info(`websocket send -> cmd: 0x${cmdId.toString(16)}, messageSeq: ${messageSeq}`);
|
13430
|
+
}
|
13431
|
+
this.socket?.send(buildWsPacketData(rpc_baseExports.NetworkRequest.encode(networkReq).finish()));
|
13432
|
+
}
|
13421
13433
|
close() {
|
13422
13434
|
this.autoReconnect = false;
|
13423
13435
|
this.doClose();
|
@@ -13533,13 +13545,22 @@ class WebSocketServer {
|
|
13533
13545
|
this.connect();
|
13534
13546
|
}, 5000);
|
13535
13547
|
}
|
13536
|
-
onConnect() {
|
13548
|
+
async onConnect() {
|
13537
13549
|
this.setStatus(ConnectionStatus.CONNECTED);
|
13538
13550
|
this.checkAlive();
|
13539
13551
|
if (isDef(this.reconnectTimer)) {
|
13540
13552
|
clearTimeout(this.reconnectTimer);
|
13541
13553
|
this.reconnectTimer = null;
|
13542
13554
|
}
|
13555
|
+
while (this.pendingMessages.length > 0) {
|
13556
|
+
let {
|
13557
|
+
cmdId,
|
13558
|
+
body,
|
13559
|
+
messageSeq
|
13560
|
+
} = this.pendingMessages.shift();
|
13561
|
+
this.doSendRawData(cmdId, body, messageSeq);
|
13562
|
+
await new Promise(resolve => setTimeout(resolve, 200));
|
13563
|
+
}
|
13543
13564
|
}
|
13544
13565
|
onDisconnect(error) {
|
13545
13566
|
if (!isDef(this.socket)) {
|
@@ -13556,6 +13577,7 @@ class WebSocketServer {
|
|
13556
13577
|
}
|
13557
13578
|
doClose() {
|
13558
13579
|
if (isDef(this.socket)) {
|
13580
|
+
this.pendingMessages.length = 0;
|
13559
13581
|
const socket = this.socket;
|
13560
13582
|
this.socket = null;
|
13561
13583
|
socket.onClose(null);
|
package/index.umd.js
CHANGED
@@ -13311,6 +13311,7 @@
|
|
13311
13311
|
failedCount = 0;
|
13312
13312
|
reconnectTimer;
|
13313
13313
|
connectResolve;
|
13314
|
+
pendingMessages = [];
|
13314
13315
|
constructor(options) {
|
13315
13316
|
this.options = Object.assign(DefaultOptions, options);
|
13316
13317
|
}
|
@@ -13389,21 +13390,15 @@
|
|
13389
13390
|
};
|
13390
13391
|
}
|
13391
13392
|
const messageSeq = this.generateMessageSeq();
|
13392
|
-
|
13393
|
-
cmdId
|
13394
|
-
|
13395
|
-
|
13396
|
-
|
13397
|
-
|
13398
|
-
|
13399
|
-
|
13400
|
-
body: body,
|
13401
|
-
deviceType: 7
|
13402
|
-
};
|
13403
|
-
if (cmdId !== CmdIds$1.Heartbean) {
|
13404
|
-
logger.info(`websocket send -> cmd: 0x${cmdId.toString(16)}, messageSeq: ${messageSeq}`);
|
13393
|
+
if (this.isConnected) {
|
13394
|
+
this.doSendRawData(cmdId, body, messageSeq);
|
13395
|
+
} else {
|
13396
|
+
this.pendingMessages.push({
|
13397
|
+
cmdId,
|
13398
|
+
body,
|
13399
|
+
messageSeq
|
13400
|
+
});
|
13405
13401
|
}
|
13406
|
-
this.socket.send(buildWsPacketData(rpc_baseExports.NetworkRequest.encode(networkReq).finish()));
|
13407
13402
|
const respData = await new Promise(resolve => {
|
13408
13403
|
this.responseCallbacks.set(messageSeq, resolve);
|
13409
13404
|
setTimeout(() => {
|
@@ -13424,6 +13419,23 @@
|
|
13424
13419
|
data: respData
|
13425
13420
|
};
|
13426
13421
|
}
|
13422
|
+
doSendRawData(cmdId, body, messageSeq) {
|
13423
|
+
const networkReq = {
|
13424
|
+
cmdId: cmdId,
|
13425
|
+
messageSeq: Long.fromNumber(messageSeq),
|
13426
|
+
deviceId: Long.fromString(accountStore.user.deviceId),
|
13427
|
+
sessionId: Long.fromString(accountStore.user.sessionId),
|
13428
|
+
uid: Long.fromString(accountStore.user.uid),
|
13429
|
+
protocolVersion: SOCKET_PROTOCOL_VER,
|
13430
|
+
destId: '',
|
13431
|
+
body: body,
|
13432
|
+
deviceType: 7
|
13433
|
+
};
|
13434
|
+
if (cmdId !== CmdIds$1.Heartbean) {
|
13435
|
+
logger.info(`websocket send -> cmd: 0x${cmdId.toString(16)}, messageSeq: ${messageSeq}`);
|
13436
|
+
}
|
13437
|
+
this.socket?.send(buildWsPacketData(rpc_baseExports.NetworkRequest.encode(networkReq).finish()));
|
13438
|
+
}
|
13427
13439
|
close() {
|
13428
13440
|
this.autoReconnect = false;
|
13429
13441
|
this.doClose();
|
@@ -13539,13 +13551,22 @@
|
|
13539
13551
|
this.connect();
|
13540
13552
|
}, 5000);
|
13541
13553
|
}
|
13542
|
-
onConnect() {
|
13554
|
+
async onConnect() {
|
13543
13555
|
this.setStatus(exports.ConnectionStatus.CONNECTED);
|
13544
13556
|
this.checkAlive();
|
13545
13557
|
if (isDef(this.reconnectTimer)) {
|
13546
13558
|
clearTimeout(this.reconnectTimer);
|
13547
13559
|
this.reconnectTimer = null;
|
13548
13560
|
}
|
13561
|
+
while (this.pendingMessages.length > 0) {
|
13562
|
+
let {
|
13563
|
+
cmdId,
|
13564
|
+
body,
|
13565
|
+
messageSeq
|
13566
|
+
} = this.pendingMessages.shift();
|
13567
|
+
this.doSendRawData(cmdId, body, messageSeq);
|
13568
|
+
await new Promise(resolve => setTimeout(resolve, 200));
|
13569
|
+
}
|
13549
13570
|
}
|
13550
13571
|
onDisconnect(error) {
|
13551
13572
|
if (!isDef(this.socket)) {
|
@@ -13562,6 +13583,7 @@
|
|
13562
13583
|
}
|
13563
13584
|
doClose() {
|
13564
13585
|
if (isDef(this.socket)) {
|
13586
|
+
this.pendingMessages.length = 0;
|
13565
13587
|
const socket = this.socket;
|
13566
13588
|
this.socket = null;
|
13567
13589
|
socket.onClose(null);
|