fcr-core 3.10.2 → 3.10.5
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 +102 -108
- package/lib/imports.js +1 -0
- package/lib/media-control/desktop.js +22 -13
- package/lib/media-control/mobile.js +27 -19
- package/lib/media-control/type.d.ts +3 -3
- package/lib/monitor-control/index.js +17 -7
- package/lib/peer-session/index.js +120 -121
- package/lib/plugins/chat/chatroom.js +119 -96
- package/lib/plugins/chat/connector.js +69 -48
- package/lib/remote-control/index.js +194 -216
- package/lib/room-control/ability-control/index.js +20 -10
- package/lib/room-control/application-control/index.js +82 -75
- package/lib/room-control/group-control/index.js +31 -30
- package/lib/room-control/helpers/board-init-info-helper.js +16 -10
- package/lib/room-control/helpers/validation-helper.js +1 -1
- package/lib/room-control/index.js +70 -51
- package/lib/room-control/infinity-room-control/index.js +27 -19
- package/lib/room-control/interpreter-control/index.js +77 -65
- package/lib/room-control/interpreter-control/room.js +6 -4
- package/lib/room-control/join-before-host-waitingroom-control/index.js +6 -4
- package/lib/room-control/mainroom-control/index.js +37 -25
- package/lib/room-control/privilege-control/helper.js +28 -13
- package/lib/room-control/privilege-control/index.js +36 -28
- package/lib/room-control/room-connector-control/index.js +52 -49
- package/lib/room-control/room-connector-control/type.d.ts +1 -1
- package/lib/room-control/room-control-factory.js +10 -12
- package/lib/room-control/room-session/index.js +77 -74
- package/lib/room-control/shared-cache.js +63 -56
- package/lib/room-control/sharing-control/index.js +65 -57
- package/lib/room-control/stream-control/index.js +197 -193
- package/lib/room-control/stt-control/de-compress-gzip.js +10 -0
- package/lib/room-control/stt-control/index.js +93 -86
- package/lib/room-control/user-control/index.js +162 -155
- package/lib/room-control/waitingroom-control/index.js +18 -9
- package/lib/room-control/whiteboard-control/utils.js +4 -2
- package/lib/room-control/whiteboard-control-v1/board-subwindow.js +2 -1
- package/lib/room-control/whiteboard-control-v1/board-window.js +120 -103
- package/lib/room-control/whiteboard-control-v1/factory.js +7 -4
- package/lib/room-control/whiteboard-control-v1/index.js +80 -67
- package/lib/room-control/whiteboard-control-v1/mount-manager.js +4 -2
- package/lib/room-control/whiteboard-control-v1/utils.js +17 -14
- package/lib/room-control/whiteboard-control-v2/annotation-control/control.js +14 -10
- package/lib/room-control/whiteboard-control-v2/annotation-control/factory.js +17 -8
- package/lib/room-control/whiteboard-control-v2/base/index.js +61 -53
- package/lib/room-control/whiteboard-control-v2/base/main-window.js +39 -30
- package/lib/room-control/whiteboard-control-v2/utils.js +10 -10
- package/lib/room-control/whiteboard-control-v2/whiteboard-control/control.js +45 -33
- package/lib/room-control/whiteboard-control-v2/whiteboard-control/factory.js +27 -11
- package/lib/room-control/widget-control/index.js +43 -33
- package/lib/room-router/index.js +66 -58
- package/lib/schema.d.ts +15 -15
- package/lib/service/api.js +446 -548
- package/lib/struct.js +5 -2
- package/lib/utilities/abortable-retry.js +3 -0
- package/lib/utilities/collection.js +15 -11
- package/lib/utilities/error-helpers.js +34 -27
- package/lib/utilities/error.js +4 -3
- package/lib/utilities/join-helper.js +37 -31
- package/lib/utilities/logger.js +8 -5
- package/lib/utilities/parameters.js +21 -10
- package/lib/utilities/retry-helpers.js +1 -0
- package/lib/utilities/stream.js +16 -11
- package/lib/utilities/user.js +4 -3
- package/lib/utilities/validate-params.js +1 -1
- package/lib/utilities/video-encoder-config.js +10 -5
- package/lib-es/engine/index.js +102 -108
- package/lib-es/media-control/desktop.js +22 -13
- package/lib-es/media-control/mobile.js +27 -19
- package/lib-es/monitor-control/index.js +16 -7
- package/lib-es/peer-session/index.js +120 -121
- package/lib-es/plugins/chat/chatroom.js +118 -95
- package/lib-es/plugins/chat/connector.js +67 -47
- package/lib-es/remote-control/index.js +194 -216
- package/lib-es/room-control/ability-control/index.js +19 -10
- package/lib-es/room-control/application-control/index.js +81 -75
- package/lib-es/room-control/group-control/index.js +31 -30
- package/lib-es/room-control/helpers/board-init-info-helper.js +15 -10
- package/lib-es/room-control/helpers/validation-helper.js +1 -1
- package/lib-es/room-control/index.js +69 -51
- package/lib-es/room-control/infinity-room-control/index.js +26 -19
- package/lib-es/room-control/interpreter-control/index.js +77 -65
- package/lib-es/room-control/interpreter-control/room.js +5 -4
- package/lib-es/room-control/join-before-host-waitingroom-control/index.js +5 -4
- package/lib-es/room-control/mainroom-control/index.js +37 -25
- package/lib-es/room-control/privilege-control/helper.js +27 -13
- package/lib-es/room-control/privilege-control/index.js +36 -28
- package/lib-es/room-control/room-connector-control/index.js +52 -49
- package/lib-es/room-control/room-control-factory.js +10 -12
- package/lib-es/room-control/room-session/index.js +77 -74
- package/lib-es/room-control/shared-cache.js +62 -56
- package/lib-es/room-control/sharing-control/index.js +64 -57
- package/lib-es/room-control/stream-control/index.js +197 -193
- package/lib-es/room-control/stt-control/de-compress-gzip.js +10 -0
- package/lib-es/room-control/stt-control/index.js +93 -86
- package/lib-es/room-control/user-control/index.js +162 -155
- package/lib-es/room-control/waitingroom-control/index.js +18 -9
- package/lib-es/room-control/whiteboard-control/utils.js +4 -2
- package/lib-es/room-control/whiteboard-control-v1/board-subwindow.js +2 -1
- package/lib-es/room-control/whiteboard-control-v1/board-window.js +120 -103
- package/lib-es/room-control/whiteboard-control-v1/factory.js +6 -4
- package/lib-es/room-control/whiteboard-control-v1/index.js +80 -67
- package/lib-es/room-control/whiteboard-control-v1/mount-manager.js +3 -2
- package/lib-es/room-control/whiteboard-control-v1/utils.js +17 -14
- package/lib-es/room-control/whiteboard-control-v2/annotation-control/control.js +13 -10
- package/lib-es/room-control/whiteboard-control-v2/annotation-control/factory.js +16 -8
- package/lib-es/room-control/whiteboard-control-v2/base/index.js +60 -53
- package/lib-es/room-control/whiteboard-control-v2/base/main-window.js +39 -30
- package/lib-es/room-control/whiteboard-control-v2/utils.js +10 -10
- package/lib-es/room-control/whiteboard-control-v2/whiteboard-control/control.js +45 -33
- package/lib-es/room-control/whiteboard-control-v2/whiteboard-control/factory.js +26 -11
- package/lib-es/room-control/widget-control/index.js +42 -33
- package/lib-es/room-router/index.js +66 -58
- package/lib-es/service/api.js +445 -548
- package/lib-es/struct.js +4 -2
- package/lib-es/utilities/abortable-retry.js +3 -0
- package/lib-es/utilities/collection.js +14 -11
- package/lib-es/utilities/error-helpers.js +33 -26
- package/lib-es/utilities/error.js +4 -3
- package/lib-es/utilities/join-helper.js +36 -29
- package/lib-es/utilities/logger.js +7 -5
- package/lib-es/utilities/parameters.js +21 -10
- package/lib-es/utilities/retry-helpers.js +1 -0
- package/lib-es/utilities/stream.js +15 -11
- package/lib-es/utilities/user.js +4 -3
- package/lib-es/utilities/validate-params.js +1 -1
- package/lib-es/utilities/video-encoder-config.js +10 -5
- package/package.json +4 -4
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
require("core-js/modules/es.symbol.description.js");
|
|
4
|
+
require("core-js/modules/es.error.cause.js");
|
|
3
5
|
require("core-js/modules/es.array.push.js");
|
|
4
6
|
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");
|
|
5
9
|
require("core-js/modules/esnext.map.delete-all.js");
|
|
6
10
|
require("core-js/modules/esnext.map.emplace.js");
|
|
7
11
|
require("core-js/modules/esnext.map.every.js");
|
|
@@ -17,6 +21,7 @@ require("core-js/modules/esnext.map.reduce.js");
|
|
|
17
21
|
require("core-js/modules/esnext.map.some.js");
|
|
18
22
|
require("core-js/modules/esnext.map.update.js");
|
|
19
23
|
require("core-js/modules/esnext.symbol.metadata.js");
|
|
24
|
+
require("core-js/modules/web.dom-collections.iterator.js");
|
|
20
25
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
21
26
|
Object.defineProperty(exports, "__esModule", {
|
|
22
27
|
value: true
|
|
@@ -24,6 +29,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
24
29
|
exports.FcrChatRoomControlImpl = void 0;
|
|
25
30
|
require("core-js/modules/esnext.iterator.constructor.js");
|
|
26
31
|
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"));
|
|
27
34
|
var _decorator = require("agora-foundation/lib/decorator");
|
|
28
35
|
var _raceCondition = require("agora-foundation/lib/utilities/race-condition");
|
|
29
36
|
var _observable = require("agora-foundation/lib/utilities/observable");
|
|
@@ -34,12 +41,15 @@ var _imports = require("../../imports");
|
|
|
34
41
|
var _type2 = require("../../room-control/chatroom-control/type");
|
|
35
42
|
var _schema = require("../../schema");
|
|
36
43
|
var _type3 = require("../../type");
|
|
37
|
-
var
|
|
44
|
+
var _abortableRetry3 = require("../../utilities/abortable-retry");
|
|
38
45
|
var _error = require("../../utilities/error");
|
|
39
46
|
var _logger = require("../../utilities/logger");
|
|
40
47
|
var _user = require("../../utilities/user");
|
|
41
48
|
var _validateParams = _interopRequireDefault(require("../../utilities/validate-params"));
|
|
42
|
-
|
|
49
|
+
var _FcrChatRoomControlImpl;
|
|
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; }
|
|
43
53
|
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)]; } }; }
|
|
44
54
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
45
55
|
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); }
|
|
@@ -50,47 +60,8 @@ const CHATROOM_ID_KEY_PATH = 'widgets.easemobIM.extra.chatRoomId';
|
|
|
50
60
|
/**
|
|
51
61
|
* @internal
|
|
52
62
|
*/
|
|
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");
|
|
53
64
|
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
|
-
};
|
|
94
65
|
get conn() {
|
|
95
66
|
if (!this._chatConnection.getConnectionInstance()) {
|
|
96
67
|
throw (0, _error.generateFcrCoreClientError)(_imports.ErrorModuleCode.FCR_ROOM_CHATROOM, _imports.DetailErrorCode.UNDEFINED_ERROR, 'chat room connection not initialized, please get chat room token first');
|
|
@@ -104,9 +75,65 @@ class FcrChatRoomControlImpl {
|
|
|
104
75
|
return this._scene.getScenePropertiesByKeyPath(CHATROOM_ID_KEY_PATH);
|
|
105
76
|
}
|
|
106
77
|
get connectionEventHandlerKey() {
|
|
107
|
-
return
|
|
78
|
+
return "chatroom".concat(this._scene.sceneId);
|
|
108
79
|
}
|
|
109
80
|
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
|
+
});
|
|
110
137
|
this._scene = _scene;
|
|
111
138
|
this._chatConnection = _chatConnection;
|
|
112
139
|
this._roomCache = sharedCache.getRoomCache(_scene.sceneId);
|
|
@@ -122,24 +149,24 @@ class FcrChatRoomControlImpl {
|
|
|
122
149
|
return this._connectionState;
|
|
123
150
|
}
|
|
124
151
|
async sendMessage(message, progress) {
|
|
152
|
+
var _message$to;
|
|
125
153
|
const msg = this._convertFcrChatRoomSendBaseMessageToAgoraChatMessage(message, progress);
|
|
126
154
|
const sendMsgRes = await this.conn.send(msg);
|
|
127
155
|
const localUserInfo = this._scene.getUser(this._scene.getLocalUser().getLocalUserId());
|
|
128
|
-
const res = {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
}),
|
|
156
|
+
const res = _objectSpread(_objectSpread({}, message.type === _type2.FcrChatRoomMessageType.Text ? {
|
|
157
|
+
content: message.content
|
|
158
|
+
} :
|
|
159
|
+
// @ts-ignore
|
|
160
|
+
{
|
|
161
|
+
url: sendMsgRes.message.url
|
|
162
|
+
}), {}, {
|
|
136
163
|
from: (0, _user.convertRteUserToFcrUser)(localUserInfo, this._roomCache),
|
|
137
164
|
id: sendMsgRes.serverMsgId,
|
|
138
165
|
type: message.type,
|
|
139
166
|
properties: message.properties,
|
|
140
167
|
timestamp: Date.now(),
|
|
141
|
-
isPrivate: !!message.to
|
|
142
|
-
};
|
|
168
|
+
isPrivate: !!((_message$to = message.to) !== null && _message$to !== void 0 && _message$to.length)
|
|
169
|
+
});
|
|
143
170
|
return res;
|
|
144
171
|
}
|
|
145
172
|
addObserver(observer) {
|
|
@@ -157,7 +184,8 @@ class FcrChatRoomControlImpl {
|
|
|
157
184
|
this._connectionState = state;
|
|
158
185
|
this._observable.notifyObservers('onConnectionStateUpdated', this._scene.sceneId, state);
|
|
159
186
|
}
|
|
160
|
-
_tryJoinChatRoom(
|
|
187
|
+
_tryJoinChatRoom() {
|
|
188
|
+
let force = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
161
189
|
if (this._chatConnection.getConnectionState() !== _type.FcrChatConnectionState.CONNECTED) {
|
|
162
190
|
return;
|
|
163
191
|
}
|
|
@@ -219,7 +247,7 @@ class FcrChatRoomControlImpl {
|
|
|
219
247
|
this.conn.leaveChatRoom({
|
|
220
248
|
roomId: this.chatRoomId,
|
|
221
249
|
success: () => {
|
|
222
|
-
this.logger.info(
|
|
250
|
+
this.logger.info("leave chat room success, room id: ".concat(this.chatRoomId, ", scene id: ").concat(this._scene.sceneId));
|
|
223
251
|
},
|
|
224
252
|
error: e => {
|
|
225
253
|
this.logger.error('leave chat room failed', e.message);
|
|
@@ -232,18 +260,19 @@ class FcrChatRoomControlImpl {
|
|
|
232
260
|
this._observable.removeAllObservers();
|
|
233
261
|
return this.leave();
|
|
234
262
|
}
|
|
235
|
-
async join(
|
|
263
|
+
async join() {
|
|
264
|
+
let force = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
236
265
|
this._chatConnection.addObserver(this._chatConnectionObserver);
|
|
237
266
|
const connectorState = this._chatConnection.getConnectionState();
|
|
238
267
|
if (connectorState !== _type.FcrChatConnectionState.CONNECTED) {
|
|
239
268
|
return _type3.FcrReturnCode.SUCCESS;
|
|
240
269
|
}
|
|
241
270
|
if (!this.chatRoomId) {
|
|
242
|
-
this.logger.warn(
|
|
271
|
+
this.logger.warn("chat room id is empty, scene id: ".concat(this._scene.sceneId));
|
|
243
272
|
return _type3.FcrReturnCode.SUCCESS;
|
|
244
273
|
}
|
|
245
274
|
if (!this._chatConnection.getConnectionInstance()) {
|
|
246
|
-
this.logger.warn(
|
|
275
|
+
this.logger.warn("chat connection instance is null, scene id: ".concat(this._scene.sceneId));
|
|
247
276
|
return _type3.FcrReturnCode.SUCCESS;
|
|
248
277
|
}
|
|
249
278
|
const chatRoomId = this.chatRoomId;
|
|
@@ -258,7 +287,7 @@ class FcrChatRoomControlImpl {
|
|
|
258
287
|
if (chatRoomConnectionState !== _type2.FcrChatRoomConnectionState.Connecting) {
|
|
259
288
|
this._setConnectionState(_type2.FcrChatRoomConnectionState.Connecting);
|
|
260
289
|
}
|
|
261
|
-
this.logger.info(
|
|
290
|
+
this.logger.info("start join chat room, room id: ".concat(chatRoomId, ", scene id: ").concat(this._scene.sceneId));
|
|
262
291
|
this._addEventListener();
|
|
263
292
|
const attemptId = ++this._joinAttemptId;
|
|
264
293
|
this._joinPromise = (async () => {
|
|
@@ -266,17 +295,22 @@ class FcrChatRoomControlImpl {
|
|
|
266
295
|
if (force && chatRoomConnectionState === _type2.FcrChatRoomConnectionState.Connected) {
|
|
267
296
|
await this._leaveChatRoomForRejoin(chatRoomId);
|
|
268
297
|
}
|
|
269
|
-
const
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
298
|
+
const _abortableRetry = (0, _abortableRetry3.abortableRetry)(async () => {
|
|
299
|
+
await this.conn.joinChatRoom({
|
|
300
|
+
roomId: chatRoomId
|
|
301
|
+
});
|
|
302
|
+
this.logger.info("join chat room success, room id: ".concat(chatRoomId, ", scene id: ").concat(this._scene.sceneId));
|
|
303
|
+
}, {
|
|
304
|
+
retriesMax: Infinity
|
|
305
|
+
}),
|
|
306
|
+
_abortableRetry2 = (0, _slicedToArray2.default)(_abortableRetry, 2),
|
|
307
|
+
abort = _abortableRetry2[0],
|
|
308
|
+
promise = _abortableRetry2[1];
|
|
277
309
|
this._abortJoinChatRoom = abort;
|
|
278
310
|
try {
|
|
279
|
-
|
|
311
|
+
var _await$timeout = await (0, _raceCondition.timeout)(promise, this._joinTimeoutMs);
|
|
312
|
+
var _await$timeout2 = (0, _slicedToArray2.default)(_await$timeout, 1);
|
|
313
|
+
error = _await$timeout2[0];
|
|
280
314
|
} catch (joinError) {
|
|
281
315
|
if (attemptId !== this._joinAttemptId) {
|
|
282
316
|
return _type3.FcrReturnCode.SUCCESS;
|
|
@@ -294,7 +328,7 @@ class FcrChatRoomControlImpl {
|
|
|
294
328
|
this.conn.leaveChatRoom({
|
|
295
329
|
roomId: chatRoomId,
|
|
296
330
|
success: () => {
|
|
297
|
-
this.logger.info(
|
|
331
|
+
this.logger.info("leave stale chat room success, room id: ".concat(chatRoomId, ", scene id: ").concat(this._scene.sceneId));
|
|
298
332
|
},
|
|
299
333
|
error: leaveError => {
|
|
300
334
|
this.logger.error('leave stale chat room failed', leaveError.message);
|
|
@@ -304,9 +338,9 @@ class FcrChatRoomControlImpl {
|
|
|
304
338
|
return _type3.FcrReturnCode.SUCCESS;
|
|
305
339
|
}
|
|
306
340
|
if (error) {
|
|
307
|
-
this.logger.error(
|
|
341
|
+
this.logger.error("join chat room failed, room id: ".concat(chatRoomId, ", scene id: ").concat(this._scene.sceneId), error.message);
|
|
308
342
|
this._setConnectionState(_type2.FcrChatRoomConnectionState.Disconnected);
|
|
309
|
-
throw (0, _error.generateFcrCoreClientError)(_error.FcrErrorModuleCode.FCR_ROOM_CHATROOM, _error.FcrErrorCode.UNDEFINED_ERROR,
|
|
343
|
+
throw (0, _error.generateFcrCoreClientError)(_error.FcrErrorModuleCode.FCR_ROOM_CHATROOM, _error.FcrErrorCode.UNDEFINED_ERROR, "join chat room failed: ".concat(error.message));
|
|
310
344
|
} else {
|
|
311
345
|
this._setConnectionState(_type2.FcrChatRoomConnectionState.Connected);
|
|
312
346
|
}
|
|
@@ -343,42 +377,25 @@ class FcrChatRoomControlImpl {
|
|
|
343
377
|
this._removeEventListener();
|
|
344
378
|
this.conn.addEventHandler(this.connectionEventHandlerKey, this.chatRoomConnectionHandler);
|
|
345
379
|
}
|
|
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
|
-
};
|
|
364
380
|
_convertAgoraChatHistoryMessageToFcrChatRoomReceiveMessage(msg) {
|
|
365
381
|
//@ts-ignore
|
|
366
382
|
switch (msg.contentsType) {
|
|
367
383
|
case 'TEXT':
|
|
368
384
|
{
|
|
385
|
+
var _msg$ext4, _msg$ext5, _msg$ext6;
|
|
369
386
|
const message = {
|
|
370
387
|
id: msg.id,
|
|
371
388
|
//@ts-ignore
|
|
372
|
-
from: msg.ext
|
|
389
|
+
from: (_msg$ext4 = msg.ext) === null || _msg$ext4 === void 0 ? void 0 : _msg$ext4.sender,
|
|
373
390
|
type: _type2.FcrChatRoomMessageType.Text,
|
|
374
391
|
//@ts-ignore
|
|
375
|
-
timestamp: parseInt(
|
|
392
|
+
timestamp: parseInt("".concat(msg.time)),
|
|
376
393
|
//@ts-ignore
|
|
377
394
|
content: msg.data,
|
|
378
395
|
//@ts-ignore
|
|
379
|
-
isPrivate: msg.ext
|
|
396
|
+
isPrivate: (_msg$ext5 = msg.ext) === null || _msg$ext5 === void 0 ? void 0 : _msg$ext5.isPrivate,
|
|
380
397
|
//@ts-ignore
|
|
381
|
-
properties: msg.ext
|
|
398
|
+
properties: (_msg$ext6 = msg.ext) === null || _msg$ext6 === void 0 ? void 0 : _msg$ext6.properties
|
|
382
399
|
};
|
|
383
400
|
return message;
|
|
384
401
|
}
|
|
@@ -389,8 +406,9 @@ class FcrChatRoomControlImpl {
|
|
|
389
406
|
switch (msg.type) {
|
|
390
407
|
case _type2.FcrChatRoomMessageType.Text:
|
|
391
408
|
{
|
|
409
|
+
var _message$to2;
|
|
392
410
|
const message = msg;
|
|
393
|
-
const isPrivate = !!message.to
|
|
411
|
+
const isPrivate = !!((_message$to2 = message.to) !== null && _message$to2 !== void 0 && _message$to2.length);
|
|
394
412
|
const localUserId = this._scene.getLocalUser().getLocalUserId();
|
|
395
413
|
const localUserInfo = this._scene.getUser(localUserId);
|
|
396
414
|
return _easemobWebsdk.default.message.create({
|
|
@@ -413,9 +431,14 @@ class FcrChatRoomControlImpl {
|
|
|
413
431
|
_handleScenePropertiesUpdated(sceneId, properties) {
|
|
414
432
|
const chatRoomId = (0, _get.default)(properties.changedProperties, CHATROOM_ID_KEY_PATH);
|
|
415
433
|
if (chatRoomId) {
|
|
416
|
-
this.logger.info(
|
|
434
|
+
this.logger.info("received chat room id change, chat room id: ".concat(chatRoomId, ", scene id: ").concat(sceneId));
|
|
417
435
|
this.join();
|
|
418
436
|
}
|
|
419
437
|
}
|
|
420
438
|
}
|
|
421
|
-
exports.FcrChatRoomControlImpl = FcrChatRoomControlImpl;
|
|
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;
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
require("core-js/modules/es.symbol.description.js");
|
|
4
|
+
require("core-js/modules/es.error.cause.js");
|
|
3
5
|
require("core-js/modules/es.array.push.js");
|
|
4
6
|
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");
|
|
5
10
|
require("core-js/modules/esnext.map.delete-all.js");
|
|
6
11
|
require("core-js/modules/esnext.map.emplace.js");
|
|
7
12
|
require("core-js/modules/esnext.map.every.js");
|
|
@@ -17,46 +22,51 @@ require("core-js/modules/esnext.map.reduce.js");
|
|
|
17
22
|
require("core-js/modules/esnext.map.some.js");
|
|
18
23
|
require("core-js/modules/esnext.map.update.js");
|
|
19
24
|
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");
|
|
20
27
|
Object.defineProperty(exports, "__esModule", {
|
|
21
28
|
value: true
|
|
22
29
|
});
|
|
23
30
|
exports.FcrChatConnectorImpl = void 0;
|
|
24
31
|
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"));
|
|
25
35
|
var _imports = require("../../imports");
|
|
26
36
|
var _type = require("../../type");
|
|
27
|
-
var
|
|
37
|
+
var _abortableRetry3 = require("../../utilities/abortable-retry");
|
|
28
38
|
var _logger = require("../../utilities/logger");
|
|
29
39
|
var _packageInfo = require("../../utilities/package-info");
|
|
30
40
|
var _config = require("./config");
|
|
31
41
|
var _type2 = require("../../chat-connector/type");
|
|
42
|
+
var _FcrChatConnectorImpl;
|
|
32
43
|
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; }
|
|
33
46
|
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)]; } }; }
|
|
34
47
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
35
48
|
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); }
|
|
36
49
|
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; }
|
|
37
50
|
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; }
|
|
38
51
|
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;
|
|
54
52
|
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);
|
|
55
65
|
this._userId = _userId;
|
|
56
66
|
this._api = _api;
|
|
57
67
|
this._chatIpList = _chatIpList;
|
|
58
68
|
this._restIpList = _restIpList;
|
|
59
|
-
this.logger.info(
|
|
69
|
+
this.logger.info("Chat Version: easemob-websdk@".concat((0, _packageInfo.getDependenciesInfo)('easemob-websdk')));
|
|
60
70
|
this._addLogObserver();
|
|
61
71
|
}
|
|
62
72
|
async login() {
|
|
@@ -103,34 +113,37 @@ class FcrChatConnectorImpl {
|
|
|
103
113
|
if (privateConfig) {
|
|
104
114
|
this.logger.info('use private config:', JSON.stringify(privateConfig));
|
|
105
115
|
}
|
|
106
|
-
const
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
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
|
|
116
|
+
const _abortableRetry = (0, _abortableRetry3.abortableRetry)(async signal => {
|
|
117
|
+
const tokenResult = await this._api.getUserToken(this._userId);
|
|
118
|
+
signal.throwIfAborted();
|
|
119
|
+
this._initConfig = tokenResult;
|
|
120
|
+
const appKey = tokenResult.appKey;
|
|
121
|
+
const connParams = _objectSpread(_objectSpread(_objectSpread({}, _config.agoraChatConfig), privateConfig), {}, {
|
|
122
|
+
appKey
|
|
123
123
|
});
|
|
124
|
-
|
|
125
|
-
this.
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
124
|
+
_imports.EasemobChatSDK.logger.setConsoleLogVisibility(false);
|
|
125
|
+
this._conn = new _imports.EasemobChatSDK.connection(connParams);
|
|
126
|
+
this._addEventListeners(this._conn);
|
|
127
|
+
try {
|
|
128
|
+
await this._conn.open({
|
|
129
|
+
accessToken: this._initConfig.token,
|
|
130
|
+
user: this._userId
|
|
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];
|
|
132
143
|
this._abortLogin = abort;
|
|
133
|
-
const
|
|
144
|
+
const _await$promise = await promise,
|
|
145
|
+
_await$promise2 = (0, _slicedToArray2.default)(_await$promise, 1),
|
|
146
|
+
error = _await$promise2[0];
|
|
134
147
|
this._abortLogin = null;
|
|
135
148
|
if (error) {
|
|
136
149
|
await this._closeConnection();
|
|
@@ -200,8 +213,9 @@ class FcrChatConnectorImpl {
|
|
|
200
213
|
this._conn = null;
|
|
201
214
|
if (conn) {
|
|
202
215
|
try {
|
|
216
|
+
var _conn$close;
|
|
203
217
|
conn.removeEventHandler('connectionListener');
|
|
204
|
-
await Promise.resolve(conn.close
|
|
218
|
+
await Promise.resolve((_conn$close = conn.close) === null || _conn$close === void 0 ? void 0 : _conn$close.call(conn));
|
|
205
219
|
} catch (error) {
|
|
206
220
|
this.logger.error('close connection error', error.message);
|
|
207
221
|
}
|
|
@@ -216,15 +230,17 @@ class FcrChatConnectorImpl {
|
|
|
216
230
|
this._observable.notifyObservers('onConnectionStateUpdated', state);
|
|
217
231
|
}
|
|
218
232
|
_getPrivateConfig() {
|
|
219
|
-
|
|
233
|
+
var _this$_chatIpList, _this$_restIpList;
|
|
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;
|
|
220
236
|
const privateConfig = {
|
|
221
237
|
isHttpDNS: false
|
|
222
238
|
// https: true,
|
|
223
239
|
};
|
|
224
|
-
if (this._chatIpList
|
|
240
|
+
if ((_this$_chatIpList2 = this._chatIpList) !== null && _this$_chatIpList2 !== void 0 && _this$_chatIpList2.length) {
|
|
225
241
|
privateConfig.url = this._chatIpList[0];
|
|
226
242
|
}
|
|
227
|
-
if (this._restIpList
|
|
243
|
+
if ((_this$_restIpList2 = this._restIpList) !== null && _this$_restIpList2 !== void 0 && _this$_restIpList2.length) {
|
|
228
244
|
privateConfig.apiUrl = this._restIpList[0];
|
|
229
245
|
}
|
|
230
246
|
privateConfig.url = 'wss://apaas-private-im.agoralab.co:13003/websocket';
|
|
@@ -280,4 +296,9 @@ class FcrChatConnectorImpl {
|
|
|
280
296
|
this.addObserver((0, _logger.generateLogObserver)(this.logger, [['onConnectionStateUpdated', ['state']]]));
|
|
281
297
|
}
|
|
282
298
|
}
|
|
283
|
-
exports.FcrChatConnectorImpl = FcrChatConnectorImpl;
|
|
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;
|