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