fcr-core 3.10.1 → 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,5 +1,9 @@
|
|
|
1
|
+
import "core-js/modules/es.symbol.description.js";
|
|
2
|
+
import "core-js/modules/es.error.cause.js";
|
|
1
3
|
import "core-js/modules/es.array.push.js";
|
|
2
4
|
import "core-js/modules/esnext.function.metadata.js";
|
|
5
|
+
import "core-js/modules/esnext.iterator.filter.js";
|
|
6
|
+
import "core-js/modules/esnext.iterator.for-each.js";
|
|
3
7
|
import "core-js/modules/esnext.map.delete-all.js";
|
|
4
8
|
import "core-js/modules/esnext.map.emplace.js";
|
|
5
9
|
import "core-js/modules/esnext.map.every.js";
|
|
@@ -15,9 +19,15 @@ import "core-js/modules/esnext.map.reduce.js";
|
|
|
15
19
|
import "core-js/modules/esnext.map.some.js";
|
|
16
20
|
import "core-js/modules/esnext.map.update.js";
|
|
17
21
|
import "core-js/modules/esnext.symbol.metadata.js";
|
|
18
|
-
|
|
22
|
+
import "core-js/modules/web.dom-collections.iterator.js";
|
|
23
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
24
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
25
|
+
var _FcrChatRoomControlImpl;
|
|
26
|
+
let _initProto, _sendMessageDecs, _addObserverDecs, _removeObserverDecs, _ref;
|
|
19
27
|
import "core-js/modules/esnext.iterator.constructor.js";
|
|
20
28
|
import "core-js/modules/esnext.iterator.map.js";
|
|
29
|
+
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; }
|
|
30
|
+
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) { _defineProperty(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; }
|
|
21
31
|
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)]; } }; }
|
|
22
32
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
23
33
|
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); }
|
|
@@ -43,47 +53,8 @@ const CHATROOM_ID_KEY_PATH = 'widgets.easemobIM.extra.chatRoomId';
|
|
|
43
53
|
/**
|
|
44
54
|
* @internal
|
|
45
55
|
*/
|
|
56
|
+
_ref = (_sendMessageDecs = [trace(['message', 'progress']), validateParams(messageSchema, progressSchema.optional())], _addObserverDecs = trace(['observer']), _removeObserverDecs = trace(['observer']), "logger");
|
|
46
57
|
export class FcrChatRoomControlImpl {
|
|
47
|
-
static {
|
|
48
|
-
[_initProto] = _applyDecs(this, [[trace, 2, "getConnectionState"], [_sendMessageDecs, 2, "sendMessage"], [_addObserverDecs, 2, "addObserver"], [_removeObserverDecs, 2, "removeObserver"], [bound, 2, "_handleJoinSceneSuccess"], [bound, 2, "_handleJoinSceneFailure"], [trace, 2, "leave"], [trace, 2, "release"], [trace, 2, "join"], [bound, 2, "_handleScenePropertiesUpdated"]], []).e;
|
|
49
|
-
}
|
|
50
|
-
[(_sendMessageDecs = [trace(['message', 'progress']), validateParams(messageSchema, progressSchema.optional())], _addObserverDecs = trace(['observer']), _removeObserverDecs = trace(['observer']), "logger")] = (_initProto(this), createLogger({
|
|
51
|
-
prefix: 'FcrChatRoomControlImpl'
|
|
52
|
-
}));
|
|
53
|
-
_observable = new AgoraObservable();
|
|
54
|
-
_connectionState = FcrChatRoomConnectionState.Disconnected;
|
|
55
|
-
_joinPromise = null;
|
|
56
|
-
_joinTimeoutMs = 30000;
|
|
57
|
-
_joinAttemptId = 0;
|
|
58
|
-
_abortJoinChatRoom = null;
|
|
59
|
-
_sceneObserver = {
|
|
60
|
-
onJoinSceneSuccess: this._handleJoinSceneSuccess,
|
|
61
|
-
onJoinSceneFailure: this._handleJoinSceneFailure,
|
|
62
|
-
onScenePropertiesUpdated: this._handleScenePropertiesUpdated
|
|
63
|
-
};
|
|
64
|
-
chatRoomConnectionHandler = {
|
|
65
|
-
onTextMessage: msg => {
|
|
66
|
-
if (msg.to !== this.chatRoomId) {
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
const message = this._convertAgoraChatMessageToFcrChatRoomReceiveMessage(msg);
|
|
70
|
-
this._observable.notifyObservers('onTextMessageReceived', this._scene.sceneId, message);
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
_chatConnectionObserver = {
|
|
74
|
-
onConnectionStateUpdated: async connectorState => {
|
|
75
|
-
const chatRoomConnectionState = this.getConnectionState();
|
|
76
|
-
if (connectorState === FcrChatConnectionState.DISCONNECTED) {
|
|
77
|
-
this._setConnectionState(FcrChatRoomConnectionState.Disconnected);
|
|
78
|
-
} else if (connectorState === FcrChatConnectionState.CONNECTED && chatRoomConnectionState !== FcrChatRoomConnectionState.Connected) {
|
|
79
|
-
this.logger.info('chat connector connected, try to join chat room');
|
|
80
|
-
this._tryJoinChatRoom();
|
|
81
|
-
} else if (connectorState === FcrChatConnectionState.CONNECTED) {
|
|
82
|
-
this.logger.info('chat connector reconnected, try to rejoin chat room');
|
|
83
|
-
this._tryJoinChatRoom(true);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
};
|
|
87
58
|
get conn() {
|
|
88
59
|
if (!this._chatConnection.getConnectionInstance()) {
|
|
89
60
|
throw generateFcrCoreClientError(ErrorModuleCode.FCR_ROOM_CHATROOM, DetailErrorCode.UNDEFINED_ERROR, 'chat room connection not initialized, please get chat room token first');
|
|
@@ -97,9 +68,65 @@ export class FcrChatRoomControlImpl {
|
|
|
97
68
|
return this._scene.getScenePropertiesByKeyPath(CHATROOM_ID_KEY_PATH);
|
|
98
69
|
}
|
|
99
70
|
get connectionEventHandlerKey() {
|
|
100
|
-
return
|
|
71
|
+
return "chatroom".concat(this._scene.sceneId);
|
|
101
72
|
}
|
|
102
73
|
constructor(_scene, _chatConnection, sharedCache, joinSceneSuccess) {
|
|
74
|
+
_defineProperty(this, _ref, (_initProto(this), createLogger({
|
|
75
|
+
prefix: 'FcrChatRoomControlImpl'
|
|
76
|
+
})));
|
|
77
|
+
_defineProperty(this, "_observable", new AgoraObservable());
|
|
78
|
+
_defineProperty(this, "_connectionState", FcrChatRoomConnectionState.Disconnected);
|
|
79
|
+
_defineProperty(this, "_joinPromise", null);
|
|
80
|
+
_defineProperty(this, "_joinTimeoutMs", 30000);
|
|
81
|
+
_defineProperty(this, "_joinAttemptId", 0);
|
|
82
|
+
_defineProperty(this, "_abortJoinChatRoom", null);
|
|
83
|
+
_defineProperty(this, "_sceneObserver", {
|
|
84
|
+
onJoinSceneSuccess: this._handleJoinSceneSuccess,
|
|
85
|
+
onJoinSceneFailure: this._handleJoinSceneFailure,
|
|
86
|
+
onScenePropertiesUpdated: this._handleScenePropertiesUpdated
|
|
87
|
+
});
|
|
88
|
+
_defineProperty(this, "chatRoomConnectionHandler", {
|
|
89
|
+
onTextMessage: msg => {
|
|
90
|
+
if (msg.to !== this.chatRoomId) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
const message = this._convertAgoraChatMessageToFcrChatRoomReceiveMessage(msg);
|
|
94
|
+
this._observable.notifyObservers('onTextMessageReceived', this._scene.sceneId, message);
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
_defineProperty(this, "_chatConnectionObserver", {
|
|
98
|
+
onConnectionStateUpdated: async connectorState => {
|
|
99
|
+
const chatRoomConnectionState = this.getConnectionState();
|
|
100
|
+
if (connectorState === FcrChatConnectionState.DISCONNECTED) {
|
|
101
|
+
this._setConnectionState(FcrChatRoomConnectionState.Disconnected);
|
|
102
|
+
} else if (connectorState === FcrChatConnectionState.CONNECTED && chatRoomConnectionState !== FcrChatRoomConnectionState.Connected) {
|
|
103
|
+
this.logger.info('chat connector connected, try to join chat room');
|
|
104
|
+
this._tryJoinChatRoom();
|
|
105
|
+
} else if (connectorState === FcrChatConnectionState.CONNECTED) {
|
|
106
|
+
this.logger.info('chat connector reconnected, try to rejoin chat room');
|
|
107
|
+
this._tryJoinChatRoom(true);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
_defineProperty(this, "_convertAgoraChatMessageToFcrChatRoomReceiveMessage", msg => {
|
|
112
|
+
switch (msg.type) {
|
|
113
|
+
case 'txt':
|
|
114
|
+
{
|
|
115
|
+
var _msg$ext, _msg$ext2, _msg$ext3;
|
|
116
|
+
const message = {
|
|
117
|
+
id: msg.id,
|
|
118
|
+
from: (_msg$ext = msg.ext) === null || _msg$ext === void 0 ? void 0 : _msg$ext.sender,
|
|
119
|
+
type: FcrChatRoomMessageType.Text,
|
|
120
|
+
timestamp: parseInt("".concat(msg.time)),
|
|
121
|
+
content: msg.msg,
|
|
122
|
+
isPrivate: (_msg$ext2 = msg.ext) === null || _msg$ext2 === void 0 ? void 0 : _msg$ext2.isPrivate,
|
|
123
|
+
properties: (_msg$ext3 = msg.ext) === null || _msg$ext3 === void 0 ? void 0 : _msg$ext3.properties
|
|
124
|
+
};
|
|
125
|
+
return message;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
throw generateFcrCoreClientError(FcrErrorModuleCode.FCR_ROOM_CHATROOM, FcrErrorCode.UNDEFINED_ERROR, 'unknown remote message type');
|
|
129
|
+
});
|
|
103
130
|
this._scene = _scene;
|
|
104
131
|
this._chatConnection = _chatConnection;
|
|
105
132
|
this._roomCache = sharedCache.getRoomCache(_scene.sceneId);
|
|
@@ -115,24 +142,24 @@ export class FcrChatRoomControlImpl {
|
|
|
115
142
|
return this._connectionState;
|
|
116
143
|
}
|
|
117
144
|
async sendMessage(message, progress) {
|
|
145
|
+
var _message$to;
|
|
118
146
|
const msg = this._convertFcrChatRoomSendBaseMessageToAgoraChatMessage(message, progress);
|
|
119
147
|
const sendMsgRes = await this.conn.send(msg);
|
|
120
148
|
const localUserInfo = this._scene.getUser(this._scene.getLocalUser().getLocalUserId());
|
|
121
|
-
const res = {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
}),
|
|
149
|
+
const res = _objectSpread(_objectSpread({}, message.type === FcrChatRoomMessageType.Text ? {
|
|
150
|
+
content: message.content
|
|
151
|
+
} :
|
|
152
|
+
// @ts-ignore
|
|
153
|
+
{
|
|
154
|
+
url: sendMsgRes.message.url
|
|
155
|
+
}), {}, {
|
|
129
156
|
from: convertRteUserToFcrUser(localUserInfo, this._roomCache),
|
|
130
157
|
id: sendMsgRes.serverMsgId,
|
|
131
158
|
type: message.type,
|
|
132
159
|
properties: message.properties,
|
|
133
160
|
timestamp: Date.now(),
|
|
134
|
-
isPrivate: !!message.to
|
|
135
|
-
};
|
|
161
|
+
isPrivate: !!((_message$to = message.to) !== null && _message$to !== void 0 && _message$to.length)
|
|
162
|
+
});
|
|
136
163
|
return res;
|
|
137
164
|
}
|
|
138
165
|
addObserver(observer) {
|
|
@@ -150,7 +177,8 @@ export class FcrChatRoomControlImpl {
|
|
|
150
177
|
this._connectionState = state;
|
|
151
178
|
this._observable.notifyObservers('onConnectionStateUpdated', this._scene.sceneId, state);
|
|
152
179
|
}
|
|
153
|
-
_tryJoinChatRoom(
|
|
180
|
+
_tryJoinChatRoom() {
|
|
181
|
+
let force = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
154
182
|
if (this._chatConnection.getConnectionState() !== FcrChatConnectionState.CONNECTED) {
|
|
155
183
|
return;
|
|
156
184
|
}
|
|
@@ -212,7 +240,7 @@ export class FcrChatRoomControlImpl {
|
|
|
212
240
|
this.conn.leaveChatRoom({
|
|
213
241
|
roomId: this.chatRoomId,
|
|
214
242
|
success: () => {
|
|
215
|
-
this.logger.info(
|
|
243
|
+
this.logger.info("leave chat room success, room id: ".concat(this.chatRoomId, ", scene id: ").concat(this._scene.sceneId));
|
|
216
244
|
},
|
|
217
245
|
error: e => {
|
|
218
246
|
this.logger.error('leave chat room failed', e.message);
|
|
@@ -225,18 +253,19 @@ export class FcrChatRoomControlImpl {
|
|
|
225
253
|
this._observable.removeAllObservers();
|
|
226
254
|
return this.leave();
|
|
227
255
|
}
|
|
228
|
-
async join(
|
|
256
|
+
async join() {
|
|
257
|
+
let force = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
229
258
|
this._chatConnection.addObserver(this._chatConnectionObserver);
|
|
230
259
|
const connectorState = this._chatConnection.getConnectionState();
|
|
231
260
|
if (connectorState !== FcrChatConnectionState.CONNECTED) {
|
|
232
261
|
return FcrReturnCode.SUCCESS;
|
|
233
262
|
}
|
|
234
263
|
if (!this.chatRoomId) {
|
|
235
|
-
this.logger.warn(
|
|
264
|
+
this.logger.warn("chat room id is empty, scene id: ".concat(this._scene.sceneId));
|
|
236
265
|
return FcrReturnCode.SUCCESS;
|
|
237
266
|
}
|
|
238
267
|
if (!this._chatConnection.getConnectionInstance()) {
|
|
239
|
-
this.logger.warn(
|
|
268
|
+
this.logger.warn("chat connection instance is null, scene id: ".concat(this._scene.sceneId));
|
|
240
269
|
return FcrReturnCode.SUCCESS;
|
|
241
270
|
}
|
|
242
271
|
const chatRoomId = this.chatRoomId;
|
|
@@ -251,7 +280,7 @@ export class FcrChatRoomControlImpl {
|
|
|
251
280
|
if (chatRoomConnectionState !== FcrChatRoomConnectionState.Connecting) {
|
|
252
281
|
this._setConnectionState(FcrChatRoomConnectionState.Connecting);
|
|
253
282
|
}
|
|
254
|
-
this.logger.info(
|
|
283
|
+
this.logger.info("start join chat room, room id: ".concat(chatRoomId, ", scene id: ").concat(this._scene.sceneId));
|
|
255
284
|
this._addEventListener();
|
|
256
285
|
const attemptId = ++this._joinAttemptId;
|
|
257
286
|
this._joinPromise = (async () => {
|
|
@@ -259,17 +288,22 @@ export class FcrChatRoomControlImpl {
|
|
|
259
288
|
if (force && chatRoomConnectionState === FcrChatRoomConnectionState.Connected) {
|
|
260
289
|
await this._leaveChatRoomForRejoin(chatRoomId);
|
|
261
290
|
}
|
|
262
|
-
const
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
291
|
+
const _abortableRetry = abortableRetry(async () => {
|
|
292
|
+
await this.conn.joinChatRoom({
|
|
293
|
+
roomId: chatRoomId
|
|
294
|
+
});
|
|
295
|
+
this.logger.info("join chat room success, room id: ".concat(chatRoomId, ", scene id: ").concat(this._scene.sceneId));
|
|
296
|
+
}, {
|
|
297
|
+
retriesMax: Infinity
|
|
298
|
+
}),
|
|
299
|
+
_abortableRetry2 = _slicedToArray(_abortableRetry, 2),
|
|
300
|
+
abort = _abortableRetry2[0],
|
|
301
|
+
promise = _abortableRetry2[1];
|
|
270
302
|
this._abortJoinChatRoom = abort;
|
|
271
303
|
try {
|
|
272
|
-
|
|
304
|
+
var _await$timeout = await timeout(promise, this._joinTimeoutMs);
|
|
305
|
+
var _await$timeout2 = _slicedToArray(_await$timeout, 1);
|
|
306
|
+
error = _await$timeout2[0];
|
|
273
307
|
} catch (joinError) {
|
|
274
308
|
if (attemptId !== this._joinAttemptId) {
|
|
275
309
|
return FcrReturnCode.SUCCESS;
|
|
@@ -287,7 +321,7 @@ export class FcrChatRoomControlImpl {
|
|
|
287
321
|
this.conn.leaveChatRoom({
|
|
288
322
|
roomId: chatRoomId,
|
|
289
323
|
success: () => {
|
|
290
|
-
this.logger.info(
|
|
324
|
+
this.logger.info("leave stale chat room success, room id: ".concat(chatRoomId, ", scene id: ").concat(this._scene.sceneId));
|
|
291
325
|
},
|
|
292
326
|
error: leaveError => {
|
|
293
327
|
this.logger.error('leave stale chat room failed', leaveError.message);
|
|
@@ -297,9 +331,9 @@ export class FcrChatRoomControlImpl {
|
|
|
297
331
|
return FcrReturnCode.SUCCESS;
|
|
298
332
|
}
|
|
299
333
|
if (error) {
|
|
300
|
-
this.logger.error(
|
|
334
|
+
this.logger.error("join chat room failed, room id: ".concat(chatRoomId, ", scene id: ").concat(this._scene.sceneId), error.message);
|
|
301
335
|
this._setConnectionState(FcrChatRoomConnectionState.Disconnected);
|
|
302
|
-
throw generateFcrCoreClientError(FcrErrorModuleCode.FCR_ROOM_CHATROOM, FcrErrorCode.UNDEFINED_ERROR,
|
|
336
|
+
throw generateFcrCoreClientError(FcrErrorModuleCode.FCR_ROOM_CHATROOM, FcrErrorCode.UNDEFINED_ERROR, "join chat room failed: ".concat(error.message));
|
|
303
337
|
} else {
|
|
304
338
|
this._setConnectionState(FcrChatRoomConnectionState.Connected);
|
|
305
339
|
}
|
|
@@ -336,42 +370,25 @@ export class FcrChatRoomControlImpl {
|
|
|
336
370
|
this._removeEventListener();
|
|
337
371
|
this.conn.addEventHandler(this.connectionEventHandlerKey, this.chatRoomConnectionHandler);
|
|
338
372
|
}
|
|
339
|
-
_convertAgoraChatMessageToFcrChatRoomReceiveMessage = msg => {
|
|
340
|
-
switch (msg.type) {
|
|
341
|
-
case 'txt':
|
|
342
|
-
{
|
|
343
|
-
const message = {
|
|
344
|
-
id: msg.id,
|
|
345
|
-
from: msg.ext?.sender,
|
|
346
|
-
type: FcrChatRoomMessageType.Text,
|
|
347
|
-
timestamp: parseInt(`${msg.time}`),
|
|
348
|
-
content: msg.msg,
|
|
349
|
-
isPrivate: msg.ext?.isPrivate,
|
|
350
|
-
properties: msg.ext?.properties
|
|
351
|
-
};
|
|
352
|
-
return message;
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
throw generateFcrCoreClientError(FcrErrorModuleCode.FCR_ROOM_CHATROOM, FcrErrorCode.UNDEFINED_ERROR, 'unknown remote message type');
|
|
356
|
-
};
|
|
357
373
|
_convertAgoraChatHistoryMessageToFcrChatRoomReceiveMessage(msg) {
|
|
358
374
|
//@ts-ignore
|
|
359
375
|
switch (msg.contentsType) {
|
|
360
376
|
case 'TEXT':
|
|
361
377
|
{
|
|
378
|
+
var _msg$ext4, _msg$ext5, _msg$ext6;
|
|
362
379
|
const message = {
|
|
363
380
|
id: msg.id,
|
|
364
381
|
//@ts-ignore
|
|
365
|
-
from: msg.ext
|
|
382
|
+
from: (_msg$ext4 = msg.ext) === null || _msg$ext4 === void 0 ? void 0 : _msg$ext4.sender,
|
|
366
383
|
type: FcrChatRoomMessageType.Text,
|
|
367
384
|
//@ts-ignore
|
|
368
|
-
timestamp: parseInt(
|
|
385
|
+
timestamp: parseInt("".concat(msg.time)),
|
|
369
386
|
//@ts-ignore
|
|
370
387
|
content: msg.data,
|
|
371
388
|
//@ts-ignore
|
|
372
|
-
isPrivate: msg.ext
|
|
389
|
+
isPrivate: (_msg$ext5 = msg.ext) === null || _msg$ext5 === void 0 ? void 0 : _msg$ext5.isPrivate,
|
|
373
390
|
//@ts-ignore
|
|
374
|
-
properties: msg.ext
|
|
391
|
+
properties: (_msg$ext6 = msg.ext) === null || _msg$ext6 === void 0 ? void 0 : _msg$ext6.properties
|
|
375
392
|
};
|
|
376
393
|
return message;
|
|
377
394
|
}
|
|
@@ -382,8 +399,9 @@ export class FcrChatRoomControlImpl {
|
|
|
382
399
|
switch (msg.type) {
|
|
383
400
|
case FcrChatRoomMessageType.Text:
|
|
384
401
|
{
|
|
402
|
+
var _message$to2;
|
|
385
403
|
const message = msg;
|
|
386
|
-
const isPrivate = !!message.to
|
|
404
|
+
const isPrivate = !!((_message$to2 = message.to) !== null && _message$to2 !== void 0 && _message$to2.length);
|
|
387
405
|
const localUserId = this._scene.getLocalUser().getLocalUserId();
|
|
388
406
|
const localUserInfo = this._scene.getUser(localUserId);
|
|
389
407
|
return EasemobChatSDK.message.create({
|
|
@@ -406,8 +424,13 @@ export class FcrChatRoomControlImpl {
|
|
|
406
424
|
_handleScenePropertiesUpdated(sceneId, properties) {
|
|
407
425
|
const chatRoomId = get(properties.changedProperties, CHATROOM_ID_KEY_PATH);
|
|
408
426
|
if (chatRoomId) {
|
|
409
|
-
this.logger.info(
|
|
427
|
+
this.logger.info("received chat room id change, chat room id: ".concat(chatRoomId, ", scene id: ").concat(sceneId));
|
|
410
428
|
this.join();
|
|
411
429
|
}
|
|
412
430
|
}
|
|
413
|
-
}
|
|
431
|
+
}
|
|
432
|
+
_FcrChatRoomControlImpl = FcrChatRoomControlImpl;
|
|
433
|
+
var _applyDecs$e = _applyDecs(_FcrChatRoomControlImpl, [[trace, 2, "getConnectionState"], [_sendMessageDecs, 2, "sendMessage"], [_addObserverDecs, 2, "addObserver"], [_removeObserverDecs, 2, "removeObserver"], [bound, 2, "_handleJoinSceneSuccess"], [bound, 2, "_handleJoinSceneFailure"], [trace, 2, "leave"], [trace, 2, "release"], [trace, 2, "join"], [bound, 2, "_handleScenePropertiesUpdated"]], []).e;
|
|
434
|
+
var _applyDecs$e2 = _slicedToArray(_applyDecs$e, 1);
|
|
435
|
+
_initProto = _applyDecs$e2[0];
|
|
436
|
+
_applyDecs$e;
|
|
@@ -1,5 +1,10 @@
|
|
|
1
|
+
import "core-js/modules/es.symbol.description.js";
|
|
2
|
+
import "core-js/modules/es.error.cause.js";
|
|
1
3
|
import "core-js/modules/es.array.push.js";
|
|
2
4
|
import "core-js/modules/esnext.function.metadata.js";
|
|
5
|
+
import "core-js/modules/esnext.iterator.constructor.js";
|
|
6
|
+
import "core-js/modules/esnext.iterator.filter.js";
|
|
7
|
+
import "core-js/modules/esnext.iterator.for-each.js";
|
|
3
8
|
import "core-js/modules/esnext.map.delete-all.js";
|
|
4
9
|
import "core-js/modules/esnext.map.emplace.js";
|
|
5
10
|
import "core-js/modules/esnext.map.every.js";
|
|
@@ -15,8 +20,15 @@ import "core-js/modules/esnext.map.reduce.js";
|
|
|
15
20
|
import "core-js/modules/esnext.map.some.js";
|
|
16
21
|
import "core-js/modules/esnext.map.update.js";
|
|
17
22
|
import "core-js/modules/esnext.symbol.metadata.js";
|
|
23
|
+
import "core-js/modules/web.dom-collections.iterator.js";
|
|
24
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
25
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
26
|
+
var _FcrChatConnectorImpl;
|
|
18
27
|
let _initProto;
|
|
28
|
+
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; }
|
|
29
|
+
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) { _defineProperty(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; }
|
|
19
30
|
import "core-js/modules/es.json.stringify.js";
|
|
31
|
+
import "core-js/modules/es.promise.finally.js";
|
|
20
32
|
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)]; } }; }
|
|
21
33
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
22
34
|
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); }
|
|
@@ -30,27 +42,24 @@ import { getDependenciesInfo } from '../../utilities/package-info';
|
|
|
30
42
|
import { agoraChatConfig } from './config';
|
|
31
43
|
import { FcrChatConnectionState } from '../../chat-connector/type';
|
|
32
44
|
export class FcrChatConnectorImpl {
|
|
33
|
-
static {
|
|
34
|
-
[_initProto] = _applyDecs(this, [[trace, 2, "login"], [trace, 2, "logout"]], []).e;
|
|
35
|
-
}
|
|
36
|
-
logger = (_initProto(this), createLogger({
|
|
37
|
-
prefix: 'FcrChatConnectorImpl'
|
|
38
|
-
}));
|
|
39
|
-
_observable = new AgoraObservable();
|
|
40
|
-
_loginPromise = null;
|
|
41
|
-
_logoutPromise = null;
|
|
42
|
-
_isLogoutRequested = false;
|
|
43
|
-
_abortLogin = null;
|
|
44
|
-
_conn = null;
|
|
45
|
-
_connectionState = FcrChatConnectionState.DISCONNECTED;
|
|
46
|
-
_reconnectionTimer = null;
|
|
47
|
-
_reconnectPromise = null;
|
|
48
45
|
constructor(_userId, _api, _chatIpList, _restIpList) {
|
|
46
|
+
_defineProperty(this, "logger", (_initProto(this), createLogger({
|
|
47
|
+
prefix: 'FcrChatConnectorImpl'
|
|
48
|
+
})));
|
|
49
|
+
_defineProperty(this, "_observable", new AgoraObservable());
|
|
50
|
+
_defineProperty(this, "_loginPromise", null);
|
|
51
|
+
_defineProperty(this, "_logoutPromise", null);
|
|
52
|
+
_defineProperty(this, "_isLogoutRequested", false);
|
|
53
|
+
_defineProperty(this, "_abortLogin", null);
|
|
54
|
+
_defineProperty(this, "_conn", null);
|
|
55
|
+
_defineProperty(this, "_connectionState", FcrChatConnectionState.DISCONNECTED);
|
|
56
|
+
_defineProperty(this, "_reconnectionTimer", null);
|
|
57
|
+
_defineProperty(this, "_reconnectPromise", null);
|
|
49
58
|
this._userId = _userId;
|
|
50
59
|
this._api = _api;
|
|
51
60
|
this._chatIpList = _chatIpList;
|
|
52
61
|
this._restIpList = _restIpList;
|
|
53
|
-
this.logger.info(
|
|
62
|
+
this.logger.info("Chat Version: easemob-websdk@".concat(getDependenciesInfo('easemob-websdk')));
|
|
54
63
|
this._addLogObserver();
|
|
55
64
|
}
|
|
56
65
|
async login() {
|
|
@@ -97,34 +106,37 @@ export class FcrChatConnectorImpl {
|
|
|
97
106
|
if (privateConfig) {
|
|
98
107
|
this.logger.info('use private config:', JSON.stringify(privateConfig));
|
|
99
108
|
}
|
|
100
|
-
const
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
...privateConfig,
|
|
108
|
-
appKey
|
|
109
|
-
};
|
|
110
|
-
EasemobChatSDK.logger.setConsoleLogVisibility(false);
|
|
111
|
-
this._conn = new EasemobChatSDK.connection(connParams);
|
|
112
|
-
this._addEventListeners(this._conn);
|
|
113
|
-
try {
|
|
114
|
-
await this._conn.open({
|
|
115
|
-
accessToken: this._initConfig.token,
|
|
116
|
-
user: this._userId
|
|
109
|
+
const _abortableRetry = abortableRetry(async signal => {
|
|
110
|
+
const tokenResult = await this._api.getUserToken(this._userId);
|
|
111
|
+
signal.throwIfAborted();
|
|
112
|
+
this._initConfig = tokenResult;
|
|
113
|
+
const appKey = tokenResult.appKey;
|
|
114
|
+
const connParams = _objectSpread(_objectSpread(_objectSpread({}, agoraChatConfig), privateConfig), {}, {
|
|
115
|
+
appKey
|
|
117
116
|
});
|
|
118
|
-
|
|
119
|
-
this.
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
117
|
+
EasemobChatSDK.logger.setConsoleLogVisibility(false);
|
|
118
|
+
this._conn = new EasemobChatSDK.connection(connParams);
|
|
119
|
+
this._addEventListeners(this._conn);
|
|
120
|
+
try {
|
|
121
|
+
await this._conn.open({
|
|
122
|
+
accessToken: this._initConfig.token,
|
|
123
|
+
user: this._userId
|
|
124
|
+
});
|
|
125
|
+
} catch (error) {
|
|
126
|
+
this.logger.error('connection open error', error.message);
|
|
127
|
+
throw error;
|
|
128
|
+
}
|
|
129
|
+
this.logger.info("login success, token: ".concat(this._initConfig.token, ", userId: ").concat(this._userId));
|
|
130
|
+
}, {
|
|
131
|
+
retriesMax: Infinity
|
|
132
|
+
}),
|
|
133
|
+
_abortableRetry2 = _slicedToArray(_abortableRetry, 2),
|
|
134
|
+
abort = _abortableRetry2[0],
|
|
135
|
+
promise = _abortableRetry2[1];
|
|
126
136
|
this._abortLogin = abort;
|
|
127
|
-
const
|
|
137
|
+
const _await$promise = await promise,
|
|
138
|
+
_await$promise2 = _slicedToArray(_await$promise, 1),
|
|
139
|
+
error = _await$promise2[0];
|
|
128
140
|
this._abortLogin = null;
|
|
129
141
|
if (error) {
|
|
130
142
|
await this._closeConnection();
|
|
@@ -194,8 +206,9 @@ export class FcrChatConnectorImpl {
|
|
|
194
206
|
this._conn = null;
|
|
195
207
|
if (conn) {
|
|
196
208
|
try {
|
|
209
|
+
var _conn$close;
|
|
197
210
|
conn.removeEventHandler('connectionListener');
|
|
198
|
-
await Promise.resolve(conn.close
|
|
211
|
+
await Promise.resolve((_conn$close = conn.close) === null || _conn$close === void 0 ? void 0 : _conn$close.call(conn));
|
|
199
212
|
} catch (error) {
|
|
200
213
|
this.logger.error('close connection error', error.message);
|
|
201
214
|
}
|
|
@@ -210,15 +223,17 @@ export class FcrChatConnectorImpl {
|
|
|
210
223
|
this._observable.notifyObservers('onConnectionStateUpdated', state);
|
|
211
224
|
}
|
|
212
225
|
_getPrivateConfig() {
|
|
213
|
-
|
|
226
|
+
var _this$_chatIpList, _this$_restIpList;
|
|
227
|
+
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) {
|
|
228
|
+
var _this$_chatIpList2, _this$_restIpList2;
|
|
214
229
|
const privateConfig = {
|
|
215
230
|
isHttpDNS: false
|
|
216
231
|
// https: true,
|
|
217
232
|
};
|
|
218
|
-
if (this._chatIpList
|
|
233
|
+
if ((_this$_chatIpList2 = this._chatIpList) !== null && _this$_chatIpList2 !== void 0 && _this$_chatIpList2.length) {
|
|
219
234
|
privateConfig.url = this._chatIpList[0];
|
|
220
235
|
}
|
|
221
|
-
if (this._restIpList
|
|
236
|
+
if ((_this$_restIpList2 = this._restIpList) !== null && _this$_restIpList2 !== void 0 && _this$_restIpList2.length) {
|
|
222
237
|
privateConfig.apiUrl = this._restIpList[0];
|
|
223
238
|
}
|
|
224
239
|
privateConfig.url = 'wss://apaas-private-im.agoralab.co:13003/websocket';
|
|
@@ -273,4 +288,9 @@ export class FcrChatConnectorImpl {
|
|
|
273
288
|
_addLogObserver() {
|
|
274
289
|
this.addObserver(generateLogObserver(this.logger, [['onConnectionStateUpdated', ['state']]]));
|
|
275
290
|
}
|
|
276
|
-
}
|
|
291
|
+
}
|
|
292
|
+
_FcrChatConnectorImpl = FcrChatConnectorImpl;
|
|
293
|
+
var _applyDecs$e = _applyDecs(_FcrChatConnectorImpl, [[trace, 2, "login"], [trace, 2, "logout"]], []).e;
|
|
294
|
+
var _applyDecs$e2 = _slicedToArray(_applyDecs$e, 1);
|
|
295
|
+
_initProto = _applyDecs$e2[0];
|
|
296
|
+
_applyDecs$e;
|