fishpi 0.0.39 → 0.0.40
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/lib/chatroom.d.ts +4 -0
- package/lib/chatroom.js +36 -18
- package/package.json +1 -1
package/lib/chatroom.d.ts
CHANGED
|
@@ -92,6 +92,10 @@ declare class ChatRoom {
|
|
|
92
92
|
*/
|
|
93
93
|
send(redpacket: RedPacket): Promise<ApiResponse<undefined>>;
|
|
94
94
|
};
|
|
95
|
+
/**
|
|
96
|
+
* 重连聊天室
|
|
97
|
+
*/
|
|
98
|
+
reconnect(error?: (ev: any) => void, close?: (ev: any) => void): Promise<void>;
|
|
95
99
|
/**
|
|
96
100
|
* 移除聊天室消息监听函数
|
|
97
101
|
* @param wsCallback 消息监听函数
|
package/lib/chatroom.js
CHANGED
|
@@ -456,19 +456,9 @@ var ChatRoom = /** @class */ (function () {
|
|
|
456
456
|
configurable: true
|
|
457
457
|
});
|
|
458
458
|
/**
|
|
459
|
-
*
|
|
460
|
-
* @param wsCallback 消息监听函数
|
|
459
|
+
* 重连聊天室
|
|
461
460
|
*/
|
|
462
|
-
ChatRoom.prototype.
|
|
463
|
-
if (this._wsCallbacks.indexOf(wsCallback) < 0)
|
|
464
|
-
return;
|
|
465
|
-
this._wsCallbacks.splice(this._wsCallbacks.indexOf(wsCallback), 1);
|
|
466
|
-
};
|
|
467
|
-
/**
|
|
468
|
-
* 添加聊天室消息监听函数
|
|
469
|
-
* @param wsCallback 消息监听函数
|
|
470
|
-
*/
|
|
471
|
-
ChatRoom.prototype.addListener = function (wsCallback, error, close) {
|
|
461
|
+
ChatRoom.prototype.reconnect = function (error, close) {
|
|
472
462
|
if (error === void 0) { error = function (ev) { }; }
|
|
473
463
|
if (close === void 0) { close = function (ev) { }; }
|
|
474
464
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -478,12 +468,6 @@ var ChatRoom = /** @class */ (function () {
|
|
|
478
468
|
return __generator(this, function (_f) {
|
|
479
469
|
switch (_f.label) {
|
|
480
470
|
case 0:
|
|
481
|
-
if (this._rws !== null) {
|
|
482
|
-
if (this._wsCallbacks.indexOf(wsCallback) < 0)
|
|
483
|
-
this._wsCallbacks.push(wsCallback);
|
|
484
|
-
return [2 /*return*/];
|
|
485
|
-
}
|
|
486
|
-
this._wsCallbacks.push(wsCallback);
|
|
487
471
|
_a = this;
|
|
488
472
|
_b = reconnecting_websocket_1.default.bind;
|
|
489
473
|
_c = [void 0, "wss://".concat(utils_1.domain, "/chat-room-channel?apiKey=").concat(this._apiKey), []];
|
|
@@ -569,6 +553,40 @@ var ChatRoom = /** @class */ (function () {
|
|
|
569
553
|
});
|
|
570
554
|
});
|
|
571
555
|
};
|
|
556
|
+
/**
|
|
557
|
+
* 移除聊天室消息监听函数
|
|
558
|
+
* @param wsCallback 消息监听函数
|
|
559
|
+
*/
|
|
560
|
+
ChatRoom.prototype.removeListener = function (wsCallback) {
|
|
561
|
+
if (this._wsCallbacks.indexOf(wsCallback) < 0)
|
|
562
|
+
return;
|
|
563
|
+
this._wsCallbacks.splice(this._wsCallbacks.indexOf(wsCallback), 1);
|
|
564
|
+
};
|
|
565
|
+
/**
|
|
566
|
+
* 添加聊天室消息监听函数
|
|
567
|
+
* @param wsCallback 消息监听函数
|
|
568
|
+
*/
|
|
569
|
+
ChatRoom.prototype.addListener = function (wsCallback, error, close) {
|
|
570
|
+
if (error === void 0) { error = function (ev) { }; }
|
|
571
|
+
if (close === void 0) { close = function (ev) { }; }
|
|
572
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
573
|
+
return __generator(this, function (_a) {
|
|
574
|
+
switch (_a.label) {
|
|
575
|
+
case 0:
|
|
576
|
+
if (this._rws !== null) {
|
|
577
|
+
if (this._wsCallbacks.indexOf(wsCallback) < 0)
|
|
578
|
+
this._wsCallbacks.push(wsCallback);
|
|
579
|
+
return [2 /*return*/];
|
|
580
|
+
}
|
|
581
|
+
this._wsCallbacks.push(wsCallback);
|
|
582
|
+
return [4 /*yield*/, this.reconnect(error, close)];
|
|
583
|
+
case 1:
|
|
584
|
+
_a.sent();
|
|
585
|
+
return [2 /*return*/];
|
|
586
|
+
}
|
|
587
|
+
});
|
|
588
|
+
});
|
|
589
|
+
};
|
|
572
590
|
return ChatRoom;
|
|
573
591
|
}());
|
|
574
592
|
exports.default = ChatRoom;
|