fcr-core 3.10.5 → 3.10.6
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/engine/index.js +108 -102
- package/lib/imports.js +0 -1
- package/lib/index.d.ts +1 -1
- package/lib/media-control/desktop.js +13 -22
- package/lib/media-control/mobile.js +13 -22
- package/lib/monitor-control/index.js +7 -17
- package/lib/peer-session/index.js +121 -120
- package/lib/plugins/chat/chatroom.js +96 -119
- package/lib/plugins/chat/connector.js +48 -69
- package/lib/remote-control/index.js +216 -194
- package/lib/room-control/ability-control/index.js +10 -20
- package/lib/room-control/application-control/index.js +75 -82
- package/lib/room-control/group-control/index.js +30 -31
- package/lib/room-control/helpers/board-init-info-helper.js +10 -16
- package/lib/room-control/helpers/validation-helper.js +1 -1
- package/lib/room-control/index.js +51 -70
- package/lib/room-control/infinity-room-control/index.js +19 -27
- package/lib/room-control/interpreter-control/index.js +65 -77
- package/lib/room-control/interpreter-control/room.js +4 -6
- package/lib/room-control/join-before-host-waitingroom-control/index.js +4 -6
- package/lib/room-control/mainroom-control/index.js +25 -37
- package/lib/room-control/privilege-control/helper.js +13 -28
- package/lib/room-control/privilege-control/index.js +28 -36
- package/lib/room-control/room-connector-control/index.js +47 -52
- package/lib/room-control/room-control-factory.js +12 -10
- package/lib/room-control/room-session/index.js +74 -77
- package/lib/room-control/shared-cache.js +56 -63
- package/lib/room-control/sharing-control/index.js +57 -65
- package/lib/room-control/stream-control/index.js +238 -203
- package/lib/room-control/stream-control/type.d.ts +11 -1
- package/lib/room-control/stt-control/de-compress-gzip.js +0 -10
- package/lib/room-control/stt-control/index.js +86 -93
- package/lib/room-control/user-control/index.js +155 -162
- package/lib/room-control/waitingroom-control/index.js +9 -18
- package/lib/room-control/whiteboard-control/utils.js +2 -4
- package/lib/room-control/whiteboard-control-v1/board-subwindow.js +1 -2
- package/lib/room-control/whiteboard-control-v1/board-window.js +103 -120
- package/lib/room-control/whiteboard-control-v1/factory.js +4 -7
- package/lib/room-control/whiteboard-control-v1/index.js +67 -80
- package/lib/room-control/whiteboard-control-v1/mount-manager.js +2 -4
- package/lib/room-control/whiteboard-control-v1/utils.js +14 -17
- package/lib/room-control/whiteboard-control-v2/annotation-control/control.js +10 -14
- package/lib/room-control/whiteboard-control-v2/annotation-control/factory.js +8 -17
- package/lib/room-control/whiteboard-control-v2/base/index.js +53 -61
- package/lib/room-control/whiteboard-control-v2/base/main-window.js +30 -39
- package/lib/room-control/whiteboard-control-v2/utils.js +10 -10
- package/lib/room-control/whiteboard-control-v2/whiteboard-control/control.js +33 -45
- package/lib/room-control/whiteboard-control-v2/whiteboard-control/factory.js +11 -27
- package/lib/room-control/widget-control/index.js +33 -43
- package/lib/room-router/index.js +58 -66
- package/lib/service/api.js +548 -446
- package/lib/struct.js +2 -5
- package/lib/type.d.ts +1 -1
- package/lib/utilities/abortable-retry.js +0 -3
- package/lib/utilities/collection.js +11 -15
- package/lib/utilities/error-helpers.js +27 -34
- package/lib/utilities/error.js +3 -4
- package/lib/utilities/join-helper.js +31 -37
- package/lib/utilities/logger.js +5 -8
- package/lib/utilities/parameters.js +10 -21
- package/lib/utilities/retry-helpers.js +0 -1
- package/lib/utilities/stream.js +11 -16
- package/lib/utilities/user.js +3 -4
- package/lib/utilities/validate-params.js +1 -1
- package/lib/utilities/video-encoder-config.js +5 -10
- package/lib-es/engine/index.js +108 -102
- package/lib-es/media-control/desktop.js +13 -22
- package/lib-es/media-control/mobile.js +13 -22
- package/lib-es/monitor-control/index.js +7 -16
- package/lib-es/peer-session/index.js +121 -120
- package/lib-es/plugins/chat/chatroom.js +95 -118
- package/lib-es/plugins/chat/connector.js +47 -67
- package/lib-es/remote-control/index.js +216 -194
- package/lib-es/room-control/ability-control/index.js +10 -19
- package/lib-es/room-control/application-control/index.js +75 -81
- package/lib-es/room-control/group-control/index.js +30 -31
- package/lib-es/room-control/helpers/board-init-info-helper.js +10 -15
- package/lib-es/room-control/helpers/validation-helper.js +1 -1
- package/lib-es/room-control/index.js +51 -69
- package/lib-es/room-control/infinity-room-control/index.js +19 -26
- package/lib-es/room-control/interpreter-control/index.js +65 -77
- package/lib-es/room-control/interpreter-control/room.js +4 -5
- package/lib-es/room-control/join-before-host-waitingroom-control/index.js +4 -5
- package/lib-es/room-control/mainroom-control/index.js +25 -37
- package/lib-es/room-control/privilege-control/helper.js +13 -27
- package/lib-es/room-control/privilege-control/index.js +28 -36
- package/lib-es/room-control/room-connector-control/index.js +47 -52
- package/lib-es/room-control/room-control-factory.js +12 -10
- package/lib-es/room-control/room-session/index.js +74 -77
- package/lib-es/room-control/shared-cache.js +56 -62
- package/lib-es/room-control/sharing-control/index.js +57 -64
- package/lib-es/room-control/stream-control/index.js +240 -205
- package/lib-es/room-control/stt-control/de-compress-gzip.js +0 -10
- package/lib-es/room-control/stt-control/index.js +86 -93
- package/lib-es/room-control/user-control/index.js +155 -162
- package/lib-es/room-control/waitingroom-control/index.js +9 -18
- package/lib-es/room-control/whiteboard-control/utils.js +2 -4
- package/lib-es/room-control/whiteboard-control-v1/board-subwindow.js +1 -2
- package/lib-es/room-control/whiteboard-control-v1/board-window.js +103 -120
- package/lib-es/room-control/whiteboard-control-v1/factory.js +4 -6
- package/lib-es/room-control/whiteboard-control-v1/index.js +67 -80
- package/lib-es/room-control/whiteboard-control-v1/mount-manager.js +2 -3
- package/lib-es/room-control/whiteboard-control-v1/utils.js +14 -17
- package/lib-es/room-control/whiteboard-control-v2/annotation-control/control.js +10 -13
- package/lib-es/room-control/whiteboard-control-v2/annotation-control/factory.js +8 -16
- package/lib-es/room-control/whiteboard-control-v2/base/index.js +53 -60
- package/lib-es/room-control/whiteboard-control-v2/base/main-window.js +30 -39
- package/lib-es/room-control/whiteboard-control-v2/utils.js +10 -10
- package/lib-es/room-control/whiteboard-control-v2/whiteboard-control/control.js +33 -45
- package/lib-es/room-control/whiteboard-control-v2/whiteboard-control/factory.js +11 -26
- package/lib-es/room-control/widget-control/index.js +33 -42
- package/lib-es/room-router/index.js +58 -66
- package/lib-es/service/api.js +548 -445
- package/lib-es/struct.js +2 -4
- package/lib-es/utilities/abortable-retry.js +0 -3
- package/lib-es/utilities/collection.js +11 -14
- package/lib-es/utilities/error-helpers.js +26 -33
- package/lib-es/utilities/error.js +3 -4
- package/lib-es/utilities/join-helper.js +29 -36
- package/lib-es/utilities/logger.js +5 -7
- package/lib-es/utilities/parameters.js +10 -21
- package/lib-es/utilities/retry-helpers.js +0 -1
- package/lib-es/utilities/stream.js +11 -15
- package/lib-es/utilities/user.js +3 -4
- package/lib-es/utilities/validate-params.js +1 -1
- package/lib-es/utilities/video-encoder-config.js +5 -10
- package/package.json +4 -4
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
require("core-js/modules/es.symbol.description.js");
|
|
4
|
-
require("core-js/modules/es.error.cause.js");
|
|
5
3
|
require("core-js/modules/es.array.push.js");
|
|
6
4
|
require("core-js/modules/esnext.function.metadata.js");
|
|
7
|
-
require("core-js/modules/esnext.iterator.filter.js");
|
|
8
|
-
require("core-js/modules/esnext.iterator.for-each.js");
|
|
9
5
|
require("core-js/modules/esnext.map.delete-all.js");
|
|
10
6
|
require("core-js/modules/esnext.map.emplace.js");
|
|
11
7
|
require("core-js/modules/esnext.map.every.js");
|
|
@@ -21,7 +17,6 @@ require("core-js/modules/esnext.map.reduce.js");
|
|
|
21
17
|
require("core-js/modules/esnext.map.some.js");
|
|
22
18
|
require("core-js/modules/esnext.map.update.js");
|
|
23
19
|
require("core-js/modules/esnext.symbol.metadata.js");
|
|
24
|
-
require("core-js/modules/web.dom-collections.iterator.js");
|
|
25
20
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
26
21
|
Object.defineProperty(exports, "__esModule", {
|
|
27
22
|
value: true
|
|
@@ -29,8 +24,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
29
24
|
exports.FcrChatRoomControlImpl = void 0;
|
|
30
25
|
require("core-js/modules/esnext.iterator.constructor.js");
|
|
31
26
|
require("core-js/modules/esnext.iterator.map.js");
|
|
32
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
33
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
34
27
|
var _decorator = require("agora-foundation/lib/decorator");
|
|
35
28
|
var _raceCondition = require("agora-foundation/lib/utilities/race-condition");
|
|
36
29
|
var _observable = require("agora-foundation/lib/utilities/observable");
|
|
@@ -41,15 +34,12 @@ var _imports = require("../../imports");
|
|
|
41
34
|
var _type2 = require("../../room-control/chatroom-control/type");
|
|
42
35
|
var _schema = require("../../schema");
|
|
43
36
|
var _type3 = require("../../type");
|
|
44
|
-
var
|
|
37
|
+
var _abortableRetry = require("../../utilities/abortable-retry");
|
|
45
38
|
var _error = require("../../utilities/error");
|
|
46
39
|
var _logger = require("../../utilities/logger");
|
|
47
40
|
var _user = require("../../utilities/user");
|
|
48
41
|
var _validateParams = _interopRequireDefault(require("../../utilities/validate-params"));
|
|
49
|
-
|
|
50
|
-
let _initProto, _sendMessageDecs, _addObserverDecs, _removeObserverDecs, _ref;
|
|
51
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
52
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
42
|
+
let _initProto, _sendMessageDecs, _addObserverDecs, _removeObserverDecs;
|
|
53
43
|
function _applyDecs(e, t, r, n, o, a) { function i(e, t, r) { return function (n, o) { return r && r(n), e[t].call(n, o); }; } function c(e, t) { for (var r = 0; r < e.length; r++) e[r].call(t); return t; } function s(e, t, r, n) { if ("function" != typeof e && (n || void 0 !== e)) throw new TypeError(t + " must " + (r || "be") + " a function" + (n ? "" : " or undefined")); return e; } function applyDec(e, t, r, n, o, a, c, u, l, f, p, d, h) { function m(e) { if (!h(e)) throw new TypeError("Attempted to access private element on non-instance"); } var y, v = t[0], g = t[3], b = !u; if (!b) { r || Array.isArray(v) || (v = [v]); var w = {}, S = [], A = 3 === o ? "get" : 4 === o || d ? "set" : "value"; f ? (p || d ? w = { get: _setFunctionName(function () { return g(this); }, n, "get"), set: function (e) { t[4](this, e); } } : w[A] = g, p || _setFunctionName(w[A], n, 2 === o ? "" : A)) : p || (w = Object.getOwnPropertyDescriptor(e, n)); } for (var P = e, j = v.length - 1; j >= 0; j -= r ? 2 : 1) { var D = v[j], E = r ? v[j - 1] : void 0, I = {}, O = { kind: ["field", "accessor", "method", "getter", "setter", "class"][o], name: n, metadata: a, addInitializer: function (e, t) { if (e.v) throw Error("attempted to call addInitializer after decoration was finished"); s(t, "An initializer", "be", !0), c.push(t); }.bind(null, I) }; try { if (b) (y = s(D.call(E, P, O), "class decorators", "return")) && (P = y);else { var k, F; O.static = l, O.private = f, f ? 2 === o ? k = function (e) { return m(e), w.value; } : (o < 4 && (k = i(w, "get", m)), 3 !== o && (F = i(w, "set", m))) : (k = function (e) { return e[n]; }, (o < 2 || 4 === o) && (F = function (e, t) { e[n] = t; })); var N = O.access = { has: f ? h.bind() : function (e) { return n in e; } }; if (k && (N.get = k), F && (N.set = F), P = D.call(E, d ? { get: w.get, set: w.set } : w[A], O), d) { if ("object" == typeof P && P) (y = s(P.get, "accessor.get")) && (w.get = y), (y = s(P.set, "accessor.set")) && (w.set = y), (y = s(P.init, "accessor.init")) && S.push(y);else if (void 0 !== P) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0"); } else s(P, (p ? "field" : "method") + " decorators", "return") && (p ? S.push(P) : w[A] = P); } } finally { I.v = !0; } } return (p || d) && u.push(function (e, t) { for (var r = S.length - 1; r >= 0; r--) t = S[r].call(e, t); return t; }), p || b || (f ? d ? u.push(i(w, "get"), i(w, "set")) : u.push(2 === o ? w[A] : i.call.bind(w[A])) : Object.defineProperty(e, n, w)), P; } function u(e, t) { return Object.defineProperty(e, Symbol.metadata || Symbol.for("Symbol.metadata"), { configurable: !0, enumerable: !0, value: t }); } if (arguments.length >= 6) var l = a[Symbol.metadata || Symbol.for("Symbol.metadata")]; var f = Object.create(null == l ? null : l), p = function (e, t, r, n) { var o, a, i = [], s = function (t) { return _checkInRHS(t) === e; }, u = new Map(); function l(e) { e && i.push(c.bind(null, e)); } for (var f = 0; f < t.length; f++) { var p = t[f]; if (Array.isArray(p)) { var d = p[1], h = p[2], m = p.length > 3, y = 16 & d, v = !!(8 & d), g = 0 == (d &= 7), b = h + "/" + v; if (!g && !m) { var w = u.get(b); if (!0 === w || 3 === w && 4 !== d || 4 === w && 3 !== d) throw Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + h); u.set(b, !(d > 2) || d); } applyDec(v ? e : e.prototype, p, y, m ? "#" + h : _toPropertyKey(h), d, n, v ? a = a || [] : o = o || [], i, v, m, g, 1 === d, v && m ? s : r); } } return l(o), l(a), i; }(e, t, o, f); return r.length || u(e, f), { e: p, get c() { var t = []; return r.length && [u(applyDec(e, [r], n, e.name, 5, f, t), f), c.bind(null, t, e)]; } }; }
|
|
54
44
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
55
45
|
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
@@ -60,8 +50,47 @@ const CHATROOM_ID_KEY_PATH = 'widgets.easemobIM.extra.chatRoomId';
|
|
|
60
50
|
/**
|
|
61
51
|
* @internal
|
|
62
52
|
*/
|
|
63
|
-
_ref = (_sendMessageDecs = [(0, _decorator.trace)(['message', 'progress']), (0, _validateParams.default)(_schema.messageSchema, _schema.progressSchema.optional())], _addObserverDecs = (0, _decorator.trace)(['observer']), _removeObserverDecs = (0, _decorator.trace)(['observer']), "logger");
|
|
64
53
|
class FcrChatRoomControlImpl {
|
|
54
|
+
static {
|
|
55
|
+
[_initProto] = _applyDecs(this, [[_decorator.trace, 2, "getConnectionState"], [_sendMessageDecs, 2, "sendMessage"], [_addObserverDecs, 2, "addObserver"], [_removeObserverDecs, 2, "removeObserver"], [_decorator.bound, 2, "_handleJoinSceneSuccess"], [_decorator.bound, 2, "_handleJoinSceneFailure"], [_decorator.trace, 2, "leave"], [_decorator.trace, 2, "release"], [_decorator.trace, 2, "join"], [_decorator.bound, 2, "_handleScenePropertiesUpdated"]], []).e;
|
|
56
|
+
}
|
|
57
|
+
[(_sendMessageDecs = [(0, _decorator.trace)(['message', 'progress']), (0, _validateParams.default)(_schema.messageSchema, _schema.progressSchema.optional())], _addObserverDecs = (0, _decorator.trace)(['observer']), _removeObserverDecs = (0, _decorator.trace)(['observer']), "logger")] = (_initProto(this), (0, _logger.createLogger)({
|
|
58
|
+
prefix: 'FcrChatRoomControlImpl'
|
|
59
|
+
}));
|
|
60
|
+
_observable = new _observable.AgoraObservable();
|
|
61
|
+
_connectionState = _type2.FcrChatRoomConnectionState.Disconnected;
|
|
62
|
+
_joinPromise = null;
|
|
63
|
+
_joinTimeoutMs = 30000;
|
|
64
|
+
_joinAttemptId = 0;
|
|
65
|
+
_abortJoinChatRoom = null;
|
|
66
|
+
_sceneObserver = {
|
|
67
|
+
onJoinSceneSuccess: this._handleJoinSceneSuccess,
|
|
68
|
+
onJoinSceneFailure: this._handleJoinSceneFailure,
|
|
69
|
+
onScenePropertiesUpdated: this._handleScenePropertiesUpdated
|
|
70
|
+
};
|
|
71
|
+
chatRoomConnectionHandler = {
|
|
72
|
+
onTextMessage: msg => {
|
|
73
|
+
if (msg.to !== this.chatRoomId) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
const message = this._convertAgoraChatMessageToFcrChatRoomReceiveMessage(msg);
|
|
77
|
+
this._observable.notifyObservers('onTextMessageReceived', this._scene.sceneId, message);
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
_chatConnectionObserver = {
|
|
81
|
+
onConnectionStateUpdated: async connectorState => {
|
|
82
|
+
const chatRoomConnectionState = this.getConnectionState();
|
|
83
|
+
if (connectorState === _type.FcrChatConnectionState.DISCONNECTED) {
|
|
84
|
+
this._setConnectionState(_type2.FcrChatRoomConnectionState.Disconnected);
|
|
85
|
+
} else if (connectorState === _type.FcrChatConnectionState.CONNECTED && chatRoomConnectionState !== _type2.FcrChatRoomConnectionState.Connected) {
|
|
86
|
+
this.logger.info('chat connector connected, try to join chat room');
|
|
87
|
+
this._tryJoinChatRoom();
|
|
88
|
+
} else if (connectorState === _type.FcrChatConnectionState.CONNECTED) {
|
|
89
|
+
this.logger.info('chat connector reconnected, try to rejoin chat room');
|
|
90
|
+
this._tryJoinChatRoom(true);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
};
|
|
65
94
|
get conn() {
|
|
66
95
|
if (!this._chatConnection.getConnectionInstance()) {
|
|
67
96
|
throw (0, _error.generateFcrCoreClientError)(_imports.ErrorModuleCode.FCR_ROOM_CHATROOM, _imports.DetailErrorCode.UNDEFINED_ERROR, 'chat room connection not initialized, please get chat room token first');
|
|
@@ -75,65 +104,9 @@ class FcrChatRoomControlImpl {
|
|
|
75
104
|
return this._scene.getScenePropertiesByKeyPath(CHATROOM_ID_KEY_PATH);
|
|
76
105
|
}
|
|
77
106
|
get connectionEventHandlerKey() {
|
|
78
|
-
return
|
|
107
|
+
return `chatroom${this._scene.sceneId}`;
|
|
79
108
|
}
|
|
80
109
|
constructor(_scene, _chatConnection, sharedCache, joinSceneSuccess) {
|
|
81
|
-
(0, _defineProperty2.default)(this, _ref, (_initProto(this), (0, _logger.createLogger)({
|
|
82
|
-
prefix: 'FcrChatRoomControlImpl'
|
|
83
|
-
})));
|
|
84
|
-
(0, _defineProperty2.default)(this, "_observable", new _observable.AgoraObservable());
|
|
85
|
-
(0, _defineProperty2.default)(this, "_connectionState", _type2.FcrChatRoomConnectionState.Disconnected);
|
|
86
|
-
(0, _defineProperty2.default)(this, "_joinPromise", null);
|
|
87
|
-
(0, _defineProperty2.default)(this, "_joinTimeoutMs", 30000);
|
|
88
|
-
(0, _defineProperty2.default)(this, "_joinAttemptId", 0);
|
|
89
|
-
(0, _defineProperty2.default)(this, "_abortJoinChatRoom", null);
|
|
90
|
-
(0, _defineProperty2.default)(this, "_sceneObserver", {
|
|
91
|
-
onJoinSceneSuccess: this._handleJoinSceneSuccess,
|
|
92
|
-
onJoinSceneFailure: this._handleJoinSceneFailure,
|
|
93
|
-
onScenePropertiesUpdated: this._handleScenePropertiesUpdated
|
|
94
|
-
});
|
|
95
|
-
(0, _defineProperty2.default)(this, "chatRoomConnectionHandler", {
|
|
96
|
-
onTextMessage: msg => {
|
|
97
|
-
if (msg.to !== this.chatRoomId) {
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
|
-
const message = this._convertAgoraChatMessageToFcrChatRoomReceiveMessage(msg);
|
|
101
|
-
this._observable.notifyObservers('onTextMessageReceived', this._scene.sceneId, message);
|
|
102
|
-
}
|
|
103
|
-
});
|
|
104
|
-
(0, _defineProperty2.default)(this, "_chatConnectionObserver", {
|
|
105
|
-
onConnectionStateUpdated: async connectorState => {
|
|
106
|
-
const chatRoomConnectionState = this.getConnectionState();
|
|
107
|
-
if (connectorState === _type.FcrChatConnectionState.DISCONNECTED) {
|
|
108
|
-
this._setConnectionState(_type2.FcrChatRoomConnectionState.Disconnected);
|
|
109
|
-
} else if (connectorState === _type.FcrChatConnectionState.CONNECTED && chatRoomConnectionState !== _type2.FcrChatRoomConnectionState.Connected) {
|
|
110
|
-
this.logger.info('chat connector connected, try to join chat room');
|
|
111
|
-
this._tryJoinChatRoom();
|
|
112
|
-
} else if (connectorState === _type.FcrChatConnectionState.CONNECTED) {
|
|
113
|
-
this.logger.info('chat connector reconnected, try to rejoin chat room');
|
|
114
|
-
this._tryJoinChatRoom(true);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
});
|
|
118
|
-
(0, _defineProperty2.default)(this, "_convertAgoraChatMessageToFcrChatRoomReceiveMessage", msg => {
|
|
119
|
-
switch (msg.type) {
|
|
120
|
-
case 'txt':
|
|
121
|
-
{
|
|
122
|
-
var _msg$ext, _msg$ext2, _msg$ext3;
|
|
123
|
-
const message = {
|
|
124
|
-
id: msg.id,
|
|
125
|
-
from: (_msg$ext = msg.ext) === null || _msg$ext === void 0 ? void 0 : _msg$ext.sender,
|
|
126
|
-
type: _type2.FcrChatRoomMessageType.Text,
|
|
127
|
-
timestamp: parseInt("".concat(msg.time)),
|
|
128
|
-
content: msg.msg,
|
|
129
|
-
isPrivate: (_msg$ext2 = msg.ext) === null || _msg$ext2 === void 0 ? void 0 : _msg$ext2.isPrivate,
|
|
130
|
-
properties: (_msg$ext3 = msg.ext) === null || _msg$ext3 === void 0 ? void 0 : _msg$ext3.properties
|
|
131
|
-
};
|
|
132
|
-
return message;
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
throw (0, _error.generateFcrCoreClientError)(_error.FcrErrorModuleCode.FCR_ROOM_CHATROOM, _error.FcrErrorCode.UNDEFINED_ERROR, 'unknown remote message type');
|
|
136
|
-
});
|
|
137
110
|
this._scene = _scene;
|
|
138
111
|
this._chatConnection = _chatConnection;
|
|
139
112
|
this._roomCache = sharedCache.getRoomCache(_scene.sceneId);
|
|
@@ -149,24 +122,24 @@ class FcrChatRoomControlImpl {
|
|
|
149
122
|
return this._connectionState;
|
|
150
123
|
}
|
|
151
124
|
async sendMessage(message, progress) {
|
|
152
|
-
var _message$to;
|
|
153
125
|
const msg = this._convertFcrChatRoomSendBaseMessageToAgoraChatMessage(message, progress);
|
|
154
126
|
const sendMsgRes = await this.conn.send(msg);
|
|
155
127
|
const localUserInfo = this._scene.getUser(this._scene.getLocalUser().getLocalUserId());
|
|
156
|
-
const res =
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
128
|
+
const res = {
|
|
129
|
+
...(message.type === _type2.FcrChatRoomMessageType.Text ? {
|
|
130
|
+
content: message.content
|
|
131
|
+
} :
|
|
132
|
+
// @ts-ignore
|
|
133
|
+
{
|
|
134
|
+
url: sendMsgRes.message.url
|
|
135
|
+
}),
|
|
163
136
|
from: (0, _user.convertRteUserToFcrUser)(localUserInfo, this._roomCache),
|
|
164
137
|
id: sendMsgRes.serverMsgId,
|
|
165
138
|
type: message.type,
|
|
166
139
|
properties: message.properties,
|
|
167
140
|
timestamp: Date.now(),
|
|
168
|
-
isPrivate: !!
|
|
169
|
-
}
|
|
141
|
+
isPrivate: !!message.to?.length
|
|
142
|
+
};
|
|
170
143
|
return res;
|
|
171
144
|
}
|
|
172
145
|
addObserver(observer) {
|
|
@@ -184,8 +157,7 @@ class FcrChatRoomControlImpl {
|
|
|
184
157
|
this._connectionState = state;
|
|
185
158
|
this._observable.notifyObservers('onConnectionStateUpdated', this._scene.sceneId, state);
|
|
186
159
|
}
|
|
187
|
-
_tryJoinChatRoom() {
|
|
188
|
-
let force = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
160
|
+
_tryJoinChatRoom(force = false) {
|
|
189
161
|
if (this._chatConnection.getConnectionState() !== _type.FcrChatConnectionState.CONNECTED) {
|
|
190
162
|
return;
|
|
191
163
|
}
|
|
@@ -247,7 +219,7 @@ class FcrChatRoomControlImpl {
|
|
|
247
219
|
this.conn.leaveChatRoom({
|
|
248
220
|
roomId: this.chatRoomId,
|
|
249
221
|
success: () => {
|
|
250
|
-
this.logger.info(
|
|
222
|
+
this.logger.info(`leave chat room success, room id: ${this.chatRoomId}, scene id: ${this._scene.sceneId}`);
|
|
251
223
|
},
|
|
252
224
|
error: e => {
|
|
253
225
|
this.logger.error('leave chat room failed', e.message);
|
|
@@ -260,19 +232,18 @@ class FcrChatRoomControlImpl {
|
|
|
260
232
|
this._observable.removeAllObservers();
|
|
261
233
|
return this.leave();
|
|
262
234
|
}
|
|
263
|
-
async join() {
|
|
264
|
-
let force = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
235
|
+
async join(force = false) {
|
|
265
236
|
this._chatConnection.addObserver(this._chatConnectionObserver);
|
|
266
237
|
const connectorState = this._chatConnection.getConnectionState();
|
|
267
238
|
if (connectorState !== _type.FcrChatConnectionState.CONNECTED) {
|
|
268
239
|
return _type3.FcrReturnCode.SUCCESS;
|
|
269
240
|
}
|
|
270
241
|
if (!this.chatRoomId) {
|
|
271
|
-
this.logger.warn(
|
|
242
|
+
this.logger.warn(`chat room id is empty, scene id: ${this._scene.sceneId}`);
|
|
272
243
|
return _type3.FcrReturnCode.SUCCESS;
|
|
273
244
|
}
|
|
274
245
|
if (!this._chatConnection.getConnectionInstance()) {
|
|
275
|
-
this.logger.warn(
|
|
246
|
+
this.logger.warn(`chat connection instance is null, scene id: ${this._scene.sceneId}`);
|
|
276
247
|
return _type3.FcrReturnCode.SUCCESS;
|
|
277
248
|
}
|
|
278
249
|
const chatRoomId = this.chatRoomId;
|
|
@@ -287,7 +258,7 @@ class FcrChatRoomControlImpl {
|
|
|
287
258
|
if (chatRoomConnectionState !== _type2.FcrChatRoomConnectionState.Connecting) {
|
|
288
259
|
this._setConnectionState(_type2.FcrChatRoomConnectionState.Connecting);
|
|
289
260
|
}
|
|
290
|
-
this.logger.info(
|
|
261
|
+
this.logger.info(`start join chat room, room id: ${chatRoomId}, scene id: ${this._scene.sceneId}`);
|
|
291
262
|
this._addEventListener();
|
|
292
263
|
const attemptId = ++this._joinAttemptId;
|
|
293
264
|
this._joinPromise = (async () => {
|
|
@@ -295,22 +266,17 @@ class FcrChatRoomControlImpl {
|
|
|
295
266
|
if (force && chatRoomConnectionState === _type2.FcrChatRoomConnectionState.Connected) {
|
|
296
267
|
await this._leaveChatRoomForRejoin(chatRoomId);
|
|
297
268
|
}
|
|
298
|
-
const
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
_abortableRetry2 = (0, _slicedToArray2.default)(_abortableRetry, 2),
|
|
307
|
-
abort = _abortableRetry2[0],
|
|
308
|
-
promise = _abortableRetry2[1];
|
|
269
|
+
const [abort, promise] = (0, _abortableRetry.abortableRetry)(async () => {
|
|
270
|
+
await this.conn.joinChatRoom({
|
|
271
|
+
roomId: chatRoomId
|
|
272
|
+
});
|
|
273
|
+
this.logger.info(`join chat room success, room id: ${chatRoomId}, scene id: ${this._scene.sceneId}`);
|
|
274
|
+
}, {
|
|
275
|
+
retriesMax: Infinity
|
|
276
|
+
});
|
|
309
277
|
this._abortJoinChatRoom = abort;
|
|
310
278
|
try {
|
|
311
|
-
|
|
312
|
-
var _await$timeout2 = (0, _slicedToArray2.default)(_await$timeout, 1);
|
|
313
|
-
error = _await$timeout2[0];
|
|
279
|
+
[error] = await (0, _raceCondition.timeout)(promise, this._joinTimeoutMs);
|
|
314
280
|
} catch (joinError) {
|
|
315
281
|
if (attemptId !== this._joinAttemptId) {
|
|
316
282
|
return _type3.FcrReturnCode.SUCCESS;
|
|
@@ -328,7 +294,7 @@ class FcrChatRoomControlImpl {
|
|
|
328
294
|
this.conn.leaveChatRoom({
|
|
329
295
|
roomId: chatRoomId,
|
|
330
296
|
success: () => {
|
|
331
|
-
this.logger.info(
|
|
297
|
+
this.logger.info(`leave stale chat room success, room id: ${chatRoomId}, scene id: ${this._scene.sceneId}`);
|
|
332
298
|
},
|
|
333
299
|
error: leaveError => {
|
|
334
300
|
this.logger.error('leave stale chat room failed', leaveError.message);
|
|
@@ -338,9 +304,9 @@ class FcrChatRoomControlImpl {
|
|
|
338
304
|
return _type3.FcrReturnCode.SUCCESS;
|
|
339
305
|
}
|
|
340
306
|
if (error) {
|
|
341
|
-
this.logger.error(
|
|
307
|
+
this.logger.error(`join chat room failed, room id: ${chatRoomId}, scene id: ${this._scene.sceneId}`, error.message);
|
|
342
308
|
this._setConnectionState(_type2.FcrChatRoomConnectionState.Disconnected);
|
|
343
|
-
throw (0, _error.generateFcrCoreClientError)(_error.FcrErrorModuleCode.FCR_ROOM_CHATROOM, _error.FcrErrorCode.UNDEFINED_ERROR,
|
|
309
|
+
throw (0, _error.generateFcrCoreClientError)(_error.FcrErrorModuleCode.FCR_ROOM_CHATROOM, _error.FcrErrorCode.UNDEFINED_ERROR, `join chat room failed: ${error.message}`);
|
|
344
310
|
} else {
|
|
345
311
|
this._setConnectionState(_type2.FcrChatRoomConnectionState.Connected);
|
|
346
312
|
}
|
|
@@ -377,25 +343,42 @@ class FcrChatRoomControlImpl {
|
|
|
377
343
|
this._removeEventListener();
|
|
378
344
|
this.conn.addEventHandler(this.connectionEventHandlerKey, this.chatRoomConnectionHandler);
|
|
379
345
|
}
|
|
346
|
+
_convertAgoraChatMessageToFcrChatRoomReceiveMessage = msg => {
|
|
347
|
+
switch (msg.type) {
|
|
348
|
+
case 'txt':
|
|
349
|
+
{
|
|
350
|
+
const message = {
|
|
351
|
+
id: msg.id,
|
|
352
|
+
from: msg.ext?.sender,
|
|
353
|
+
type: _type2.FcrChatRoomMessageType.Text,
|
|
354
|
+
timestamp: parseInt(`${msg.time}`),
|
|
355
|
+
content: msg.msg,
|
|
356
|
+
isPrivate: msg.ext?.isPrivate,
|
|
357
|
+
properties: msg.ext?.properties
|
|
358
|
+
};
|
|
359
|
+
return message;
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
throw (0, _error.generateFcrCoreClientError)(_error.FcrErrorModuleCode.FCR_ROOM_CHATROOM, _error.FcrErrorCode.UNDEFINED_ERROR, 'unknown remote message type');
|
|
363
|
+
};
|
|
380
364
|
_convertAgoraChatHistoryMessageToFcrChatRoomReceiveMessage(msg) {
|
|
381
365
|
//@ts-ignore
|
|
382
366
|
switch (msg.contentsType) {
|
|
383
367
|
case 'TEXT':
|
|
384
368
|
{
|
|
385
|
-
var _msg$ext4, _msg$ext5, _msg$ext6;
|
|
386
369
|
const message = {
|
|
387
370
|
id: msg.id,
|
|
388
371
|
//@ts-ignore
|
|
389
|
-
from:
|
|
372
|
+
from: msg.ext?.sender,
|
|
390
373
|
type: _type2.FcrChatRoomMessageType.Text,
|
|
391
374
|
//@ts-ignore
|
|
392
|
-
timestamp: parseInt(
|
|
375
|
+
timestamp: parseInt(`${msg.time}`),
|
|
393
376
|
//@ts-ignore
|
|
394
377
|
content: msg.data,
|
|
395
378
|
//@ts-ignore
|
|
396
|
-
isPrivate:
|
|
379
|
+
isPrivate: msg.ext?.isPrivate,
|
|
397
380
|
//@ts-ignore
|
|
398
|
-
properties:
|
|
381
|
+
properties: msg.ext?.properties
|
|
399
382
|
};
|
|
400
383
|
return message;
|
|
401
384
|
}
|
|
@@ -406,9 +389,8 @@ class FcrChatRoomControlImpl {
|
|
|
406
389
|
switch (msg.type) {
|
|
407
390
|
case _type2.FcrChatRoomMessageType.Text:
|
|
408
391
|
{
|
|
409
|
-
var _message$to2;
|
|
410
392
|
const message = msg;
|
|
411
|
-
const isPrivate = !!
|
|
393
|
+
const isPrivate = !!message.to?.length;
|
|
412
394
|
const localUserId = this._scene.getLocalUser().getLocalUserId();
|
|
413
395
|
const localUserInfo = this._scene.getUser(localUserId);
|
|
414
396
|
return _easemobWebsdk.default.message.create({
|
|
@@ -431,14 +413,9 @@ class FcrChatRoomControlImpl {
|
|
|
431
413
|
_handleScenePropertiesUpdated(sceneId, properties) {
|
|
432
414
|
const chatRoomId = (0, _get.default)(properties.changedProperties, CHATROOM_ID_KEY_PATH);
|
|
433
415
|
if (chatRoomId) {
|
|
434
|
-
this.logger.info(
|
|
416
|
+
this.logger.info(`received chat room id change, chat room id: ${chatRoomId}, scene id: ${sceneId}`);
|
|
435
417
|
this.join();
|
|
436
418
|
}
|
|
437
419
|
}
|
|
438
420
|
}
|
|
439
|
-
exports.FcrChatRoomControlImpl = FcrChatRoomControlImpl;
|
|
440
|
-
_FcrChatRoomControlImpl = FcrChatRoomControlImpl;
|
|
441
|
-
var _applyDecs$e = _applyDecs(_FcrChatRoomControlImpl, [[_decorator.trace, 2, "getConnectionState"], [_sendMessageDecs, 2, "sendMessage"], [_addObserverDecs, 2, "addObserver"], [_removeObserverDecs, 2, "removeObserver"], [_decorator.bound, 2, "_handleJoinSceneSuccess"], [_decorator.bound, 2, "_handleJoinSceneFailure"], [_decorator.trace, 2, "leave"], [_decorator.trace, 2, "release"], [_decorator.trace, 2, "join"], [_decorator.bound, 2, "_handleScenePropertiesUpdated"]], []).e;
|
|
442
|
-
var _applyDecs$e2 = (0, _slicedToArray2.default)(_applyDecs$e, 1);
|
|
443
|
-
_initProto = _applyDecs$e2[0];
|
|
444
|
-
_applyDecs$e;
|
|
421
|
+
exports.FcrChatRoomControlImpl = FcrChatRoomControlImpl;
|
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
require("core-js/modules/es.symbol.description.js");
|
|
4
|
-
require("core-js/modules/es.error.cause.js");
|
|
5
3
|
require("core-js/modules/es.array.push.js");
|
|
6
4
|
require("core-js/modules/esnext.function.metadata.js");
|
|
7
|
-
require("core-js/modules/esnext.iterator.constructor.js");
|
|
8
|
-
require("core-js/modules/esnext.iterator.filter.js");
|
|
9
|
-
require("core-js/modules/esnext.iterator.for-each.js");
|
|
10
5
|
require("core-js/modules/esnext.map.delete-all.js");
|
|
11
6
|
require("core-js/modules/esnext.map.emplace.js");
|
|
12
7
|
require("core-js/modules/esnext.map.every.js");
|
|
@@ -22,51 +17,46 @@ require("core-js/modules/esnext.map.reduce.js");
|
|
|
22
17
|
require("core-js/modules/esnext.map.some.js");
|
|
23
18
|
require("core-js/modules/esnext.map.update.js");
|
|
24
19
|
require("core-js/modules/esnext.symbol.metadata.js");
|
|
25
|
-
require("core-js/modules/web.dom-collections.iterator.js");
|
|
26
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
27
20
|
Object.defineProperty(exports, "__esModule", {
|
|
28
21
|
value: true
|
|
29
22
|
});
|
|
30
23
|
exports.FcrChatConnectorImpl = void 0;
|
|
31
24
|
require("core-js/modules/es.json.stringify.js");
|
|
32
|
-
require("core-js/modules/es.promise.finally.js");
|
|
33
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
34
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
35
25
|
var _imports = require("../../imports");
|
|
36
26
|
var _type = require("../../type");
|
|
37
|
-
var
|
|
27
|
+
var _abortableRetry = require("../../utilities/abortable-retry");
|
|
38
28
|
var _logger = require("../../utilities/logger");
|
|
39
29
|
var _packageInfo = require("../../utilities/package-info");
|
|
40
30
|
var _config = require("./config");
|
|
41
31
|
var _type2 = require("../../chat-connector/type");
|
|
42
|
-
var _FcrChatConnectorImpl;
|
|
43
32
|
let _initProto;
|
|
44
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
45
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
46
33
|
function _applyDecs(e, t, r, n, o, a) { function i(e, t, r) { return function (n, o) { return r && r(n), e[t].call(n, o); }; } function c(e, t) { for (var r = 0; r < e.length; r++) e[r].call(t); return t; } function s(e, t, r, n) { if ("function" != typeof e && (n || void 0 !== e)) throw new TypeError(t + " must " + (r || "be") + " a function" + (n ? "" : " or undefined")); return e; } function applyDec(e, t, r, n, o, a, c, u, l, f, p, d, h) { function m(e) { if (!h(e)) throw new TypeError("Attempted to access private element on non-instance"); } var y, v = t[0], g = t[3], b = !u; if (!b) { r || Array.isArray(v) || (v = [v]); var w = {}, S = [], A = 3 === o ? "get" : 4 === o || d ? "set" : "value"; f ? (p || d ? w = { get: _setFunctionName(function () { return g(this); }, n, "get"), set: function (e) { t[4](this, e); } } : w[A] = g, p || _setFunctionName(w[A], n, 2 === o ? "" : A)) : p || (w = Object.getOwnPropertyDescriptor(e, n)); } for (var P = e, j = v.length - 1; j >= 0; j -= r ? 2 : 1) { var D = v[j], E = r ? v[j - 1] : void 0, I = {}, O = { kind: ["field", "accessor", "method", "getter", "setter", "class"][o], name: n, metadata: a, addInitializer: function (e, t) { if (e.v) throw Error("attempted to call addInitializer after decoration was finished"); s(t, "An initializer", "be", !0), c.push(t); }.bind(null, I) }; try { if (b) (y = s(D.call(E, P, O), "class decorators", "return")) && (P = y);else { var k, F; O.static = l, O.private = f, f ? 2 === o ? k = function (e) { return m(e), w.value; } : (o < 4 && (k = i(w, "get", m)), 3 !== o && (F = i(w, "set", m))) : (k = function (e) { return e[n]; }, (o < 2 || 4 === o) && (F = function (e, t) { e[n] = t; })); var N = O.access = { has: f ? h.bind() : function (e) { return n in e; } }; if (k && (N.get = k), F && (N.set = F), P = D.call(E, d ? { get: w.get, set: w.set } : w[A], O), d) { if ("object" == typeof P && P) (y = s(P.get, "accessor.get")) && (w.get = y), (y = s(P.set, "accessor.set")) && (w.set = y), (y = s(P.init, "accessor.init")) && S.push(y);else if (void 0 !== P) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0"); } else s(P, (p ? "field" : "method") + " decorators", "return") && (p ? S.push(P) : w[A] = P); } } finally { I.v = !0; } } return (p || d) && u.push(function (e, t) { for (var r = S.length - 1; r >= 0; r--) t = S[r].call(e, t); return t; }), p || b || (f ? d ? u.push(i(w, "get"), i(w, "set")) : u.push(2 === o ? w[A] : i.call.bind(w[A])) : Object.defineProperty(e, n, w)), P; } function u(e, t) { return Object.defineProperty(e, Symbol.metadata || Symbol.for("Symbol.metadata"), { configurable: !0, enumerable: !0, value: t }); } if (arguments.length >= 6) var l = a[Symbol.metadata || Symbol.for("Symbol.metadata")]; var f = Object.create(null == l ? null : l), p = function (e, t, r, n) { var o, a, i = [], s = function (t) { return _checkInRHS(t) === e; }, u = new Map(); function l(e) { e && i.push(c.bind(null, e)); } for (var f = 0; f < t.length; f++) { var p = t[f]; if (Array.isArray(p)) { var d = p[1], h = p[2], m = p.length > 3, y = 16 & d, v = !!(8 & d), g = 0 == (d &= 7), b = h + "/" + v; if (!g && !m) { var w = u.get(b); if (!0 === w || 3 === w && 4 !== d || 4 === w && 3 !== d) throw Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + h); u.set(b, !(d > 2) || d); } applyDec(v ? e : e.prototype, p, y, m ? "#" + h : _toPropertyKey(h), d, n, v ? a = a || [] : o = o || [], i, v, m, g, 1 === d, v && m ? s : r); } } return l(o), l(a), i; }(e, t, o, f); return r.length || u(e, f), { e: p, get c() { var t = []; return r.length && [u(applyDec(e, [r], n, e.name, 5, f, t), f), c.bind(null, t, e)]; } }; }
|
|
47
34
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
48
35
|
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
49
36
|
function _setFunctionName(e, t, n) { "symbol" == typeof t && (t = (t = t.description) ? "[" + t + "]" : ""); try { Object.defineProperty(e, "name", { configurable: !0, value: n ? n + " " + t : t }); } catch (e) {} return e; }
|
|
50
37
|
function _checkInRHS(e) { if (Object(e) !== e) throw TypeError("right-hand side of 'in' should be an object, got " + (null !== e ? typeof e : "null")); return e; }
|
|
51
38
|
class FcrChatConnectorImpl {
|
|
39
|
+
static {
|
|
40
|
+
[_initProto] = _applyDecs(this, [[_imports.trace, 2, "login"], [_imports.trace, 2, "logout"]], []).e;
|
|
41
|
+
}
|
|
42
|
+
logger = (_initProto(this), (0, _logger.createLogger)({
|
|
43
|
+
prefix: 'FcrChatConnectorImpl'
|
|
44
|
+
}));
|
|
45
|
+
_observable = new _imports.AgoraObservable();
|
|
46
|
+
_loginPromise = null;
|
|
47
|
+
_logoutPromise = null;
|
|
48
|
+
_isLogoutRequested = false;
|
|
49
|
+
_abortLogin = null;
|
|
50
|
+
_conn = null;
|
|
51
|
+
_connectionState = _type2.FcrChatConnectionState.DISCONNECTED;
|
|
52
|
+
_reconnectionTimer = null;
|
|
53
|
+
_reconnectPromise = null;
|
|
52
54
|
constructor(_userId, _api, _chatIpList, _restIpList) {
|
|
53
|
-
(0, _defineProperty2.default)(this, "logger", (_initProto(this), (0, _logger.createLogger)({
|
|
54
|
-
prefix: 'FcrChatConnectorImpl'
|
|
55
|
-
})));
|
|
56
|
-
(0, _defineProperty2.default)(this, "_observable", new _imports.AgoraObservable());
|
|
57
|
-
(0, _defineProperty2.default)(this, "_loginPromise", null);
|
|
58
|
-
(0, _defineProperty2.default)(this, "_logoutPromise", null);
|
|
59
|
-
(0, _defineProperty2.default)(this, "_isLogoutRequested", false);
|
|
60
|
-
(0, _defineProperty2.default)(this, "_abortLogin", null);
|
|
61
|
-
(0, _defineProperty2.default)(this, "_conn", null);
|
|
62
|
-
(0, _defineProperty2.default)(this, "_connectionState", _type2.FcrChatConnectionState.DISCONNECTED);
|
|
63
|
-
(0, _defineProperty2.default)(this, "_reconnectionTimer", null);
|
|
64
|
-
(0, _defineProperty2.default)(this, "_reconnectPromise", null);
|
|
65
55
|
this._userId = _userId;
|
|
66
56
|
this._api = _api;
|
|
67
57
|
this._chatIpList = _chatIpList;
|
|
68
58
|
this._restIpList = _restIpList;
|
|
69
|
-
this.logger.info(
|
|
59
|
+
this.logger.info(`Chat Version: easemob-websdk@${(0, _packageInfo.getDependenciesInfo)('easemob-websdk')}`);
|
|
70
60
|
this._addLogObserver();
|
|
71
61
|
}
|
|
72
62
|
async login() {
|
|
@@ -113,37 +103,34 @@ class FcrChatConnectorImpl {
|
|
|
113
103
|
if (privateConfig) {
|
|
114
104
|
this.logger.info('use private config:', JSON.stringify(privateConfig));
|
|
115
105
|
}
|
|
116
|
-
const
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
106
|
+
const [abort, promise] = (0, _abortableRetry.abortableRetry)(async signal => {
|
|
107
|
+
const tokenResult = await this._api.getUserToken(this._userId);
|
|
108
|
+
signal.throwIfAborted();
|
|
109
|
+
this._initConfig = tokenResult;
|
|
110
|
+
const appKey = tokenResult.appKey;
|
|
111
|
+
const connParams = {
|
|
112
|
+
..._config.agoraChatConfig,
|
|
113
|
+
...privateConfig,
|
|
114
|
+
appKey
|
|
115
|
+
};
|
|
116
|
+
_imports.EasemobChatSDK.logger.setConsoleLogVisibility(false);
|
|
117
|
+
this._conn = new _imports.EasemobChatSDK.connection(connParams);
|
|
118
|
+
this._addEventListeners(this._conn);
|
|
119
|
+
try {
|
|
120
|
+
await this._conn.open({
|
|
121
|
+
accessToken: this._initConfig.token,
|
|
122
|
+
user: this._userId
|
|
123
123
|
});
|
|
124
|
-
|
|
125
|
-
this.
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
} catch (error) {
|
|
133
|
-
this.logger.error('connection open error', error.message);
|
|
134
|
-
throw error;
|
|
135
|
-
}
|
|
136
|
-
this.logger.info("login success, token: ".concat(this._initConfig.token, ", userId: ").concat(this._userId));
|
|
137
|
-
}, {
|
|
138
|
-
retriesMax: Infinity
|
|
139
|
-
}),
|
|
140
|
-
_abortableRetry2 = (0, _slicedToArray2.default)(_abortableRetry, 2),
|
|
141
|
-
abort = _abortableRetry2[0],
|
|
142
|
-
promise = _abortableRetry2[1];
|
|
124
|
+
} catch (error) {
|
|
125
|
+
this.logger.error('connection open error', error.message);
|
|
126
|
+
throw error;
|
|
127
|
+
}
|
|
128
|
+
this.logger.info(`login success, token: ${this._initConfig.token}, userId: ${this._userId}`);
|
|
129
|
+
}, {
|
|
130
|
+
retriesMax: Infinity
|
|
131
|
+
});
|
|
143
132
|
this._abortLogin = abort;
|
|
144
|
-
const
|
|
145
|
-
_await$promise2 = (0, _slicedToArray2.default)(_await$promise, 1),
|
|
146
|
-
error = _await$promise2[0];
|
|
133
|
+
const [error] = await promise;
|
|
147
134
|
this._abortLogin = null;
|
|
148
135
|
if (error) {
|
|
149
136
|
await this._closeConnection();
|
|
@@ -213,9 +200,8 @@ class FcrChatConnectorImpl {
|
|
|
213
200
|
this._conn = null;
|
|
214
201
|
if (conn) {
|
|
215
202
|
try {
|
|
216
|
-
var _conn$close;
|
|
217
203
|
conn.removeEventHandler('connectionListener');
|
|
218
|
-
await Promise.resolve(
|
|
204
|
+
await Promise.resolve(conn.close?.());
|
|
219
205
|
} catch (error) {
|
|
220
206
|
this.logger.error('close connection error', error.message);
|
|
221
207
|
}
|
|
@@ -230,17 +216,15 @@ class FcrChatConnectorImpl {
|
|
|
230
216
|
this._observable.notifyObservers('onConnectionStateUpdated', state);
|
|
231
217
|
}
|
|
232
218
|
_getPrivateConfig() {
|
|
233
|
-
|
|
234
|
-
if ((_this$_chatIpList = this._chatIpList) !== null && _this$_chatIpList !== void 0 && _this$_chatIpList.length || (_this$_restIpList = this._restIpList) !== null && _this$_restIpList !== void 0 && _this$_restIpList.length) {
|
|
235
|
-
var _this$_chatIpList2, _this$_restIpList2;
|
|
219
|
+
if (this._chatIpList?.length || this._restIpList?.length) {
|
|
236
220
|
const privateConfig = {
|
|
237
221
|
isHttpDNS: false
|
|
238
222
|
// https: true,
|
|
239
223
|
};
|
|
240
|
-
if (
|
|
224
|
+
if (this._chatIpList?.length) {
|
|
241
225
|
privateConfig.url = this._chatIpList[0];
|
|
242
226
|
}
|
|
243
|
-
if (
|
|
227
|
+
if (this._restIpList?.length) {
|
|
244
228
|
privateConfig.apiUrl = this._restIpList[0];
|
|
245
229
|
}
|
|
246
230
|
privateConfig.url = 'wss://apaas-private-im.agoralab.co:13003/websocket';
|
|
@@ -296,9 +280,4 @@ class FcrChatConnectorImpl {
|
|
|
296
280
|
this.addObserver((0, _logger.generateLogObserver)(this.logger, [['onConnectionStateUpdated', ['state']]]));
|
|
297
281
|
}
|
|
298
282
|
}
|
|
299
|
-
exports.FcrChatConnectorImpl = FcrChatConnectorImpl;
|
|
300
|
-
_FcrChatConnectorImpl = FcrChatConnectorImpl;
|
|
301
|
-
var _applyDecs$e = _applyDecs(_FcrChatConnectorImpl, [[_imports.trace, 2, "login"], [_imports.trace, 2, "logout"]], []).e;
|
|
302
|
-
var _applyDecs$e2 = (0, _slicedToArray2.default)(_applyDecs$e, 1);
|
|
303
|
-
_initProto = _applyDecs$e2[0];
|
|
304
|
-
_applyDecs$e;
|
|
283
|
+
exports.FcrChatConnectorImpl = FcrChatConnectorImpl;
|