fcr-core 3.6.2 → 3.6.4
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/chat-connection/index.js +23 -41
- package/lib/engine/index.js +66 -65
- package/lib/imports.js +1 -3
- package/lib/media-control/desktop.js +7 -15
- package/lib/media-control/mobile.js +11 -18
- package/lib/monitor-control/index.js +3 -10
- package/lib/peer-session/index.js +37 -50
- package/lib/plugins/chatroom.js +184 -203
- package/lib/room-control/ability-control/index.js +7 -14
- package/lib/room-control/ability-control/type.d.ts +2 -1
- package/lib/room-control/ability-control/type.js +1 -0
- package/lib/room-control/group-control/index.js +14 -23
- package/lib/room-control/index.js +57 -84
- package/lib/room-control/interpreter-control/index.js +17 -25
- 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 +10 -20
- package/lib/room-control/privilege-control/helper.js +5 -10
- package/lib/room-control/privilege-control/index.js +17 -29
- package/lib/room-control/privilege-control/type.js +1 -0
- package/lib/room-control/room-connector-control/index.js +14 -25
- package/lib/room-control/room-session/index.js +37 -50
- package/lib/room-control/shared-cache.js +19 -26
- package/lib/room-control/sharing-control/index.js +22 -33
- package/lib/room-control/stream-control/index.js +164 -176
- package/lib/room-control/user-control/index.js +131 -146
- package/lib/room-control/waitingroom-control/index.js +8 -15
- package/lib/room-control/whiteboard-control/board-window.js +52 -60
- package/lib/room-control/whiteboard-control/enums.js +84 -0
- package/lib/room-control/whiteboard-control/index.js +26 -40
- package/lib/room-control/whiteboard-control/mount-manager.js +2 -4
- package/lib/room-control/whiteboard-control/utils.js +14 -17
- package/lib/room-control/whiteboard-control-v2/annotation-control/index.d.ts +1 -1
- package/lib/room-control/whiteboard-control-v2/annotation-control/index.js +20 -27
- package/lib/room-control/whiteboard-control-v2/index.d.ts +1 -1
- package/lib/room-control/whiteboard-control-v2/index.js +51 -55
- package/lib/room-control/whiteboard-control-v2/main-window.d.ts +2 -0
- package/lib/room-control/whiteboard-control-v2/main-window.js +32 -41
- package/lib/room-router/index.js +52 -70
- package/lib/schema.d.ts +15 -15
- package/lib/schema.js +0 -1
- package/lib/service/api.js +113 -117
- package/lib/type.js +4 -2
- package/lib/utilities/collection.js +2 -3
- package/lib/utilities/error.js +4 -6
- package/lib/utilities/logger.js +2 -3
- package/lib/utilities/parameters.js +4 -8
- package/lib/utilities/stream.js +12 -20
- package/lib/utilities/user.js +2 -3
- package/lib/utilities/validate-params.js +1 -2
- package/package.json +4 -4
- package/lib/room-control/whiteboard-control-v2/whiteboard-control/index.d.ts +0 -38
- package/lib/room-control/whiteboard-control-v2/whiteboard-control/index.js +0 -261
package/lib/plugins/chatroom.js
CHANGED
|
@@ -1,13 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
require("core-js/modules/es.symbol.description.js");
|
|
4
3
|
require("core-js/modules/es.array.push.js");
|
|
5
|
-
require("core-js/modules/esnext.async-iterator.filter.js");
|
|
6
|
-
require("core-js/modules/esnext.async-iterator.for-each.js");
|
|
7
4
|
require("core-js/modules/esnext.function.metadata.js");
|
|
8
|
-
require("core-js/modules/esnext.iterator.constructor.js");
|
|
9
|
-
require("core-js/modules/esnext.iterator.filter.js");
|
|
10
|
-
require("core-js/modules/esnext.iterator.for-each.js");
|
|
11
5
|
require("core-js/modules/esnext.map.delete-all.js");
|
|
12
6
|
require("core-js/modules/esnext.map.emplace.js");
|
|
13
7
|
require("core-js/modules/esnext.map.every.js");
|
|
@@ -28,11 +22,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
28
22
|
value: true
|
|
29
23
|
});
|
|
30
24
|
exports.FcrChatRoomControlImpl = void 0;
|
|
31
|
-
require("core-js/modules/
|
|
32
|
-
require("core-js/modules/esnext.async-iterator.map.js");
|
|
25
|
+
require("core-js/modules/esnext.iterator.constructor.js");
|
|
33
26
|
require("core-js/modules/esnext.iterator.map.js");
|
|
34
|
-
require("core-js/modules/web.dom-collections.iterator.js");
|
|
35
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
36
27
|
var _imports = require("../imports");
|
|
37
28
|
var _observable = require("agora-foundation/lib/utilities/observable");
|
|
38
29
|
var _easemobWebsdk = _interopRequireDefault(require("easemob-websdk"));
|
|
@@ -43,20 +34,38 @@ var _type2 = require("../chat-connection/type");
|
|
|
43
34
|
var _logger = require("../utilities/logger");
|
|
44
35
|
var _validateParams = _interopRequireDefault(require("../utilities/validate-params"));
|
|
45
36
|
var _schema = require("../schema");
|
|
46
|
-
|
|
47
|
-
let _initProto, _sendMessageDecs, _ref;
|
|
48
|
-
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; }
|
|
49
|
-
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; }
|
|
37
|
+
let _initProto, _sendMessageDecs;
|
|
50
38
|
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)]; } }; }
|
|
51
39
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
52
40
|
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
41
|
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; }
|
|
54
42
|
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; }
|
|
55
|
-
_ref = (_sendMessageDecs = [_imports.trace, (0, _validateParams.default)(_schema.messageSchema, _schema.progressSchema.optional())], "logger");
|
|
56
43
|
/**
|
|
57
44
|
* @internal
|
|
58
45
|
*/
|
|
59
46
|
class FcrChatRoomControlImpl {
|
|
47
|
+
static #_ = (() => [_initProto] = _applyDecs(this, [[_imports.trace, 2, "join"], [_imports.trace, 2, "getConnectionState"], [_imports.trace, 2, "leave"], [_sendMessageDecs, 2, "sendMessage"], [_imports.trace, 2, "addObserver"], [_imports.trace, 2, "removeObserver"]], []).e)();
|
|
48
|
+
[(_sendMessageDecs = [_imports.trace, (0, _validateParams.default)(_schema.messageSchema, _schema.progressSchema.optional())], "logger")] = (() => (_initProto(this), (0, _logger.createLogger)({
|
|
49
|
+
prefix: 'FcrChatRoomControlImpl'
|
|
50
|
+
})))();
|
|
51
|
+
_observable = (() => new _observable.AgoraObservable())();
|
|
52
|
+
_connectionState = (() => _type.FcrChatRoomConnectionState.Disconnected)();
|
|
53
|
+
_chatConnectionObserver = {
|
|
54
|
+
onConnectionStateUpdated: async state => {
|
|
55
|
+
// im reconnect
|
|
56
|
+
this.logger.info(`onConnectionStateUpdated, chatConnectionState: ${state}, chatControlState: ${this.getConnectionState()}`);
|
|
57
|
+
if (state === _type2.FcrChatConnectionState.DISCONNECTED && this.getConnectionState() === _type.FcrChatRoomConnectionState.Connected) {
|
|
58
|
+
this._setConnectionState(_type.FcrChatRoomConnectionState.Disconnected);
|
|
59
|
+
} else if (state === _type2.FcrChatConnectionState.CONNECTED && this.getConnectionState() !== _type.FcrChatRoomConnectionState.Connected) {
|
|
60
|
+
this._removeEventListener();
|
|
61
|
+
this._addEventListener();
|
|
62
|
+
await this._joinChatRoom(state);
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
onConnectionLoginSuccess: () => {
|
|
66
|
+
this._addEventListener();
|
|
67
|
+
}
|
|
68
|
+
};
|
|
60
69
|
get conn() {
|
|
61
70
|
if (!this._chatConnection.getConnectionInstance()) {
|
|
62
71
|
throw (0, _error.generateFcrCoreClientError)(_error.FcrErrorModuleCode.ROOM_CHATROOM, _error.FcrErrorCode.UNDEFINED_ERROR, 'chat room connection not initialized, please get chat room token first', new Error('chat room connection not initialized, please get chat room token first'));
|
|
@@ -67,177 +76,6 @@ class FcrChatRoomControlImpl {
|
|
|
67
76
|
return this._scene.getScenePropertiesByKeyPath('widgets.easemobIM.extra.chatRoomId');
|
|
68
77
|
}
|
|
69
78
|
constructor(_scene, _chatConnection, _sharedCache) {
|
|
70
|
-
(0, _defineProperty2.default)(this, _ref, (_initProto(this), (0, _logger.createLogger)({
|
|
71
|
-
prefix: 'FcrChatRoomControlImpl'
|
|
72
|
-
})));
|
|
73
|
-
(0, _defineProperty2.default)(this, "_observable", new _observable.AgoraObservable());
|
|
74
|
-
(0, _defineProperty2.default)(this, "_connectionState", _type.FcrChatRoomConnectionState.Disconnected);
|
|
75
|
-
(0, _defineProperty2.default)(this, "_chatConnectionObserver", {
|
|
76
|
-
onConnectionStateUpdated: async state => {
|
|
77
|
-
// im reconnect
|
|
78
|
-
this.logger.info("onConnectionStateUpdated, chatConnectionState: ".concat(state, ", chatControlState: ").concat(this.getConnectionState()));
|
|
79
|
-
if (state === _type2.FcrChatConnectionState.DISCONNECTED && this.getConnectionState() === _type.FcrChatRoomConnectionState.Connected) {
|
|
80
|
-
this._setConnectionState(_type.FcrChatRoomConnectionState.Disconnected);
|
|
81
|
-
} else if (state === _type2.FcrChatConnectionState.CONNECTED && this.getConnectionState() !== _type.FcrChatRoomConnectionState.Connected) {
|
|
82
|
-
this._removeEventListener();
|
|
83
|
-
this._addEventListener();
|
|
84
|
-
await this._joinChatRoom(state);
|
|
85
|
-
}
|
|
86
|
-
},
|
|
87
|
-
onConnectionLoginSuccess: () => {
|
|
88
|
-
this._addEventListener();
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
(0, _defineProperty2.default)(this, "_joinChatRoom", async state => {
|
|
92
|
-
this.logger.info("joinChatRoom, chatConnectionState: ".concat(state, ", chatControlState: ").concat(this.getConnectionState()));
|
|
93
|
-
if (state === _type2.FcrChatConnectionState.CONNECTED && this.getConnectionState() === _type.FcrChatRoomConnectionState.Disconnected && this.chatRoomId) {
|
|
94
|
-
this._setConnectionState(_type.FcrChatRoomConnectionState.Connecting);
|
|
95
|
-
this.logger.info("start join chat room, room id: ".concat(this.chatRoomId, ", scene id: ").concat(this._scene.sceneId));
|
|
96
|
-
await this.conn.joinChatRoom({
|
|
97
|
-
roomId: this.chatRoomId
|
|
98
|
-
});
|
|
99
|
-
this._setConnectionState(_type.FcrChatRoomConnectionState.Connected);
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
|
-
(0, _defineProperty2.default)(this, "_convertAgoraChatMessageToFcrChatRoomReceiveMessage", msg => {
|
|
103
|
-
// TODO: 没看到有 contentsType 字段
|
|
104
|
-
//@ts-ignore
|
|
105
|
-
switch (msg.type) {
|
|
106
|
-
case 'txt':
|
|
107
|
-
{
|
|
108
|
-
var _msg$ext, _msg$ext2;
|
|
109
|
-
const message = {
|
|
110
|
-
id: msg.id,
|
|
111
|
-
//@ts-ignore
|
|
112
|
-
from: msg.ext.sender,
|
|
113
|
-
type: _type.FcrChatRoomMessageType.Text,
|
|
114
|
-
//@ts-ignore
|
|
115
|
-
timestamp: parseInt(msg.time),
|
|
116
|
-
//@ts-ignore
|
|
117
|
-
content: msg.msg,
|
|
118
|
-
isPrivate: (_msg$ext = msg.ext) === null || _msg$ext === void 0 ? void 0 : _msg$ext.isPrivate,
|
|
119
|
-
properties: (_msg$ext2 = msg.ext) === null || _msg$ext2 === void 0 ? void 0 : _msg$ext2.properties
|
|
120
|
-
};
|
|
121
|
-
return message;
|
|
122
|
-
}
|
|
123
|
-
case 'img':
|
|
124
|
-
{
|
|
125
|
-
var _msg$ext3, _msg$ext4, _msg$ext5;
|
|
126
|
-
const message = {
|
|
127
|
-
id: msg.id,
|
|
128
|
-
from: (_msg$ext3 = msg.ext) === null || _msg$ext3 === void 0 ? void 0 : _msg$ext3.sender,
|
|
129
|
-
type: _type.FcrChatRoomMessageType.Image,
|
|
130
|
-
//@ts-ignore
|
|
131
|
-
timestamp: parseInt(msg.time),
|
|
132
|
-
url: msg.url || '',
|
|
133
|
-
isPrivate: (_msg$ext4 = msg.ext) === null || _msg$ext4 === void 0 ? void 0 : _msg$ext4.isPrivate,
|
|
134
|
-
properties: (_msg$ext5 = msg.ext) === null || _msg$ext5 === void 0 ? void 0 : _msg$ext5.properties
|
|
135
|
-
};
|
|
136
|
-
return message;
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
throw (0, _error.generateFcrCoreClientError)(_error.FcrErrorModuleCode.ROOM_CHATROOM, _error.FcrErrorCode.UNDEFINED_ERROR, 'unknown remote message type', new Error('unknown remote message type'));
|
|
140
|
-
});
|
|
141
|
-
(0, _defineProperty2.default)(this, "_convertAgoraChatHistoryMessageToFcrChatRoomReceiveMessage", msg => {
|
|
142
|
-
// TODO: 没看到有 contentsType 字段
|
|
143
|
-
//@ts-ignore
|
|
144
|
-
switch (msg.contentsType) {
|
|
145
|
-
case 'TEXT':
|
|
146
|
-
{
|
|
147
|
-
var _msg$ext6;
|
|
148
|
-
const message = {
|
|
149
|
-
id: msg.id,
|
|
150
|
-
//@ts-ignore
|
|
151
|
-
from: msg.ext.sender,
|
|
152
|
-
type: _type.FcrChatRoomMessageType.Text,
|
|
153
|
-
//@ts-ignore
|
|
154
|
-
timestamp: parseInt(msg.time),
|
|
155
|
-
//@ts-ignore
|
|
156
|
-
content: msg.data,
|
|
157
|
-
//@ts-ignore
|
|
158
|
-
isPrivate: msg.ext.isPrivate,
|
|
159
|
-
//@ts-ignore
|
|
160
|
-
properties: (_msg$ext6 = msg.ext) === null || _msg$ext6 === void 0 ? void 0 : _msg$ext6.properties
|
|
161
|
-
};
|
|
162
|
-
return message;
|
|
163
|
-
}
|
|
164
|
-
case 'IMAGE':
|
|
165
|
-
{
|
|
166
|
-
var _msg$ext7, _msg$ext8, _msg$ext9;
|
|
167
|
-
const message = {
|
|
168
|
-
id: msg.id,
|
|
169
|
-
//@ts-ignore
|
|
170
|
-
from: (_msg$ext7 = msg.ext) === null || _msg$ext7 === void 0 ? void 0 : _msg$ext7.sender,
|
|
171
|
-
type: _type.FcrChatRoomMessageType.Image,
|
|
172
|
-
//@ts-ignore
|
|
173
|
-
timestamp: parseInt(msg.time),
|
|
174
|
-
//@ts-ignore
|
|
175
|
-
url: msg.url || '',
|
|
176
|
-
//@ts-ignore
|
|
177
|
-
isPrivate: (_msg$ext8 = msg.ext) === null || _msg$ext8 === void 0 ? void 0 : _msg$ext8.isPrivate,
|
|
178
|
-
//@ts-ignore
|
|
179
|
-
properties: (_msg$ext9 = msg.ext) === null || _msg$ext9 === void 0 ? void 0 : _msg$ext9.properties
|
|
180
|
-
};
|
|
181
|
-
return message;
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
throw (0, _error.generateFcrCoreClientError)(_error.FcrErrorModuleCode.ROOM_CHATROOM, _error.FcrErrorCode.UNDEFINED_ERROR, 'unknown remote message type', new Error('unknown remote message type'));
|
|
185
|
-
});
|
|
186
|
-
(0, _defineProperty2.default)(this, "_convertFcrChatRoomSendBaseMessageToAgoraChatMessage", (msg, progress) => {
|
|
187
|
-
switch (msg.type) {
|
|
188
|
-
case _type.FcrChatRoomMessageType.Text:
|
|
189
|
-
{
|
|
190
|
-
var _message$to;
|
|
191
|
-
const message = msg;
|
|
192
|
-
const isPrivate = !!((_message$to = message.to) !== null && _message$to !== void 0 && _message$to.length);
|
|
193
|
-
const localUserId = this._scene.getLocalUser().getLocalUserId();
|
|
194
|
-
const localUserInfo = this._scene.getUser(localUserId);
|
|
195
|
-
return _easemobWebsdk.default.message.create({
|
|
196
|
-
to: this.chatRoomId,
|
|
197
|
-
msg: message.content,
|
|
198
|
-
type: 'txt',
|
|
199
|
-
chatType: 'chatRoom',
|
|
200
|
-
ext: {
|
|
201
|
-
sender: (0, _user.convertRteUserToFcrUser)(localUserInfo, this._roomCache),
|
|
202
|
-
roomUuid: this._scene.sceneId,
|
|
203
|
-
isPrivate,
|
|
204
|
-
properties: msg.properties
|
|
205
|
-
},
|
|
206
|
-
receiverList: message.to
|
|
207
|
-
});
|
|
208
|
-
}
|
|
209
|
-
case _type.FcrChatRoomMessageType.Image:
|
|
210
|
-
{
|
|
211
|
-
var _imageMessage$to;
|
|
212
|
-
const imageMessage = msg;
|
|
213
|
-
const isPrivateImage = !!((_imageMessage$to = imageMessage.to) !== null && _imageMessage$to !== void 0 && _imageMessage$to.length);
|
|
214
|
-
const localUser = this._scene.getUser(this._scene.getLocalUser().getLocalUserId());
|
|
215
|
-
return _easemobWebsdk.default.message.create({
|
|
216
|
-
to: this.chatRoomId,
|
|
217
|
-
type: 'img',
|
|
218
|
-
chatType: 'chatRoom',
|
|
219
|
-
url: imageMessage.file.filePath,
|
|
220
|
-
file: {
|
|
221
|
-
filename: imageMessage.file.fileName,
|
|
222
|
-
filetype: imageMessage.file.fileType,
|
|
223
|
-
data: imageMessage.file.data,
|
|
224
|
-
url: ''
|
|
225
|
-
},
|
|
226
|
-
ext: {
|
|
227
|
-
sender: (0, _user.convertRteUserToFcrUser)(localUser, this._roomCache),
|
|
228
|
-
roomUuid: this._scene.sceneId,
|
|
229
|
-
isPrivate: isPrivateImage,
|
|
230
|
-
properties: msg.properties
|
|
231
|
-
},
|
|
232
|
-
receiverList: imageMessage.to,
|
|
233
|
-
onFileUploadProgress: e => {
|
|
234
|
-
progress === null || progress === void 0 || progress(Math.round(e.loaded / e.total * 100));
|
|
235
|
-
}
|
|
236
|
-
});
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
throw (0, _error.generateFcrCoreClientError)(_error.FcrErrorModuleCode.ROOM_CHATROOM, _error.FcrErrorCode.UNDEFINED_ERROR, 'unknown local message type', new Error('unknown local message type'));
|
|
240
|
-
});
|
|
241
79
|
this._scene = _scene;
|
|
242
80
|
this._chatConnection = _chatConnection;
|
|
243
81
|
this._sharedCache = _sharedCache;
|
|
@@ -276,12 +114,23 @@ class FcrChatRoomControlImpl {
|
|
|
276
114
|
}
|
|
277
115
|
});
|
|
278
116
|
}
|
|
117
|
+
_joinChatRoom = async state => {
|
|
118
|
+
this.logger.info(`joinChatRoom, chatConnectionState: ${state}, chatControlState: ${this.getConnectionState()}`);
|
|
119
|
+
if (state === _type2.FcrChatConnectionState.CONNECTED && this.getConnectionState() === _type.FcrChatRoomConnectionState.Disconnected && this.chatRoomId) {
|
|
120
|
+
this._setConnectionState(_type.FcrChatRoomConnectionState.Connecting);
|
|
121
|
+
this.logger.info(`start join chat room, room id: ${this.chatRoomId}, scene id: ${this._scene.sceneId}`);
|
|
122
|
+
await this.conn.joinChatRoom({
|
|
123
|
+
roomId: this.chatRoomId
|
|
124
|
+
});
|
|
125
|
+
this._setConnectionState(_type.FcrChatRoomConnectionState.Connected);
|
|
126
|
+
}
|
|
127
|
+
};
|
|
279
128
|
_removeEventListener() {
|
|
280
|
-
this.conn.removeEventHandler(
|
|
129
|
+
this.conn.removeEventHandler(`chatroom${this._scene.sceneId}`);
|
|
281
130
|
}
|
|
282
131
|
_addEventListener() {
|
|
283
132
|
this._removeEventListener();
|
|
284
|
-
this.conn.addEventHandler(
|
|
133
|
+
this.conn.addEventHandler(`chatroom${this._scene.sceneId}`, {
|
|
285
134
|
onTextMessage: msg => {
|
|
286
135
|
if (msg.to !== this.chatRoomId) {
|
|
287
136
|
return;
|
|
@@ -296,9 +145,10 @@ class FcrChatRoomControlImpl {
|
|
|
296
145
|
}
|
|
297
146
|
// 这里的数据结构和 onTextMessage 不一样,实际上contentsType是img ,type是chatroom,
|
|
298
147
|
// 但是因为在onPictureMessage的回调中,所以这里直接用type: 'img',后续可以考虑优化
|
|
299
|
-
const message = this._convertAgoraChatMessageToFcrChatRoomReceiveMessage(
|
|
148
|
+
const message = this._convertAgoraChatMessageToFcrChatRoomReceiveMessage({
|
|
149
|
+
...msg,
|
|
300
150
|
type: 'img'
|
|
301
|
-
})
|
|
151
|
+
});
|
|
302
152
|
this._observable.notifyObservers('onImageMessageReceived', this._scene.sceneId, message);
|
|
303
153
|
};
|
|
304
154
|
|
|
@@ -326,25 +176,158 @@ class FcrChatRoomControlImpl {
|
|
|
326
176
|
// }
|
|
327
177
|
// };
|
|
328
178
|
}
|
|
179
|
+
_convertAgoraChatMessageToFcrChatRoomReceiveMessage = msg => {
|
|
180
|
+
// TODO: 没看到有 contentsType 字段
|
|
181
|
+
//@ts-ignore
|
|
182
|
+
switch (msg.type) {
|
|
183
|
+
case 'txt':
|
|
184
|
+
{
|
|
185
|
+
const message = {
|
|
186
|
+
id: msg.id,
|
|
187
|
+
//@ts-ignore
|
|
188
|
+
from: msg.ext.sender,
|
|
189
|
+
type: _type.FcrChatRoomMessageType.Text,
|
|
190
|
+
//@ts-ignore
|
|
191
|
+
timestamp: parseInt(msg.time),
|
|
192
|
+
//@ts-ignore
|
|
193
|
+
content: msg.msg,
|
|
194
|
+
isPrivate: msg.ext?.isPrivate,
|
|
195
|
+
properties: msg.ext?.properties
|
|
196
|
+
};
|
|
197
|
+
return message;
|
|
198
|
+
}
|
|
199
|
+
case 'img':
|
|
200
|
+
{
|
|
201
|
+
const message = {
|
|
202
|
+
id: msg.id,
|
|
203
|
+
from: msg.ext?.sender,
|
|
204
|
+
type: _type.FcrChatRoomMessageType.Image,
|
|
205
|
+
//@ts-ignore
|
|
206
|
+
timestamp: parseInt(msg.time),
|
|
207
|
+
url: msg.url || '',
|
|
208
|
+
isPrivate: msg.ext?.isPrivate,
|
|
209
|
+
properties: msg.ext?.properties
|
|
210
|
+
};
|
|
211
|
+
return message;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
throw (0, _error.generateFcrCoreClientError)(_error.FcrErrorModuleCode.ROOM_CHATROOM, _error.FcrErrorCode.UNDEFINED_ERROR, 'unknown remote message type', new Error('unknown remote message type'));
|
|
215
|
+
};
|
|
216
|
+
_convertAgoraChatHistoryMessageToFcrChatRoomReceiveMessage = msg => {
|
|
217
|
+
// TODO: 没看到有 contentsType 字段
|
|
218
|
+
//@ts-ignore
|
|
219
|
+
switch (msg.contentsType) {
|
|
220
|
+
case 'TEXT':
|
|
221
|
+
{
|
|
222
|
+
const message = {
|
|
223
|
+
id: msg.id,
|
|
224
|
+
//@ts-ignore
|
|
225
|
+
from: msg.ext.sender,
|
|
226
|
+
type: _type.FcrChatRoomMessageType.Text,
|
|
227
|
+
//@ts-ignore
|
|
228
|
+
timestamp: parseInt(msg.time),
|
|
229
|
+
//@ts-ignore
|
|
230
|
+
content: msg.data,
|
|
231
|
+
//@ts-ignore
|
|
232
|
+
isPrivate: msg.ext.isPrivate,
|
|
233
|
+
//@ts-ignore
|
|
234
|
+
properties: msg.ext?.properties
|
|
235
|
+
};
|
|
236
|
+
return message;
|
|
237
|
+
}
|
|
238
|
+
case 'IMAGE':
|
|
239
|
+
{
|
|
240
|
+
const message = {
|
|
241
|
+
id: msg.id,
|
|
242
|
+
//@ts-ignore
|
|
243
|
+
from: msg.ext?.sender,
|
|
244
|
+
type: _type.FcrChatRoomMessageType.Image,
|
|
245
|
+
//@ts-ignore
|
|
246
|
+
timestamp: parseInt(msg.time),
|
|
247
|
+
//@ts-ignore
|
|
248
|
+
url: msg.url || '',
|
|
249
|
+
//@ts-ignore
|
|
250
|
+
isPrivate: msg.ext?.isPrivate,
|
|
251
|
+
//@ts-ignore
|
|
252
|
+
properties: msg.ext?.properties
|
|
253
|
+
};
|
|
254
|
+
return message;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
throw (0, _error.generateFcrCoreClientError)(_error.FcrErrorModuleCode.ROOM_CHATROOM, _error.FcrErrorCode.UNDEFINED_ERROR, 'unknown remote message type', new Error('unknown remote message type'));
|
|
258
|
+
};
|
|
259
|
+
_convertFcrChatRoomSendBaseMessageToAgoraChatMessage = (msg, progress) => {
|
|
260
|
+
switch (msg.type) {
|
|
261
|
+
case _type.FcrChatRoomMessageType.Text:
|
|
262
|
+
{
|
|
263
|
+
const message = msg;
|
|
264
|
+
const isPrivate = !!message.to?.length;
|
|
265
|
+
const localUserId = this._scene.getLocalUser().getLocalUserId();
|
|
266
|
+
const localUserInfo = this._scene.getUser(localUserId);
|
|
267
|
+
return _easemobWebsdk.default.message.create({
|
|
268
|
+
to: this.chatRoomId,
|
|
269
|
+
msg: message.content,
|
|
270
|
+
type: 'txt',
|
|
271
|
+
chatType: 'chatRoom',
|
|
272
|
+
ext: {
|
|
273
|
+
sender: (0, _user.convertRteUserToFcrUser)(localUserInfo, this._roomCache),
|
|
274
|
+
roomUuid: this._scene.sceneId,
|
|
275
|
+
isPrivate,
|
|
276
|
+
properties: msg.properties
|
|
277
|
+
},
|
|
278
|
+
receiverList: message.to
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
case _type.FcrChatRoomMessageType.Image:
|
|
282
|
+
{
|
|
283
|
+
const imageMessage = msg;
|
|
284
|
+
const isPrivateImage = !!imageMessage.to?.length;
|
|
285
|
+
const localUser = this._scene.getUser(this._scene.getLocalUser().getLocalUserId());
|
|
286
|
+
return _easemobWebsdk.default.message.create({
|
|
287
|
+
to: this.chatRoomId,
|
|
288
|
+
type: 'img',
|
|
289
|
+
chatType: 'chatRoom',
|
|
290
|
+
url: imageMessage.file.filePath,
|
|
291
|
+
file: {
|
|
292
|
+
filename: imageMessage.file.fileName,
|
|
293
|
+
filetype: imageMessage.file.fileType,
|
|
294
|
+
data: imageMessage.file.data,
|
|
295
|
+
url: ''
|
|
296
|
+
},
|
|
297
|
+
ext: {
|
|
298
|
+
sender: (0, _user.convertRteUserToFcrUser)(localUser, this._roomCache),
|
|
299
|
+
roomUuid: this._scene.sceneId,
|
|
300
|
+
isPrivate: isPrivateImage,
|
|
301
|
+
properties: msg.properties
|
|
302
|
+
},
|
|
303
|
+
receiverList: imageMessage.to,
|
|
304
|
+
onFileUploadProgress: e => {
|
|
305
|
+
progress?.(Math.round(e.loaded / e.total * 100));
|
|
306
|
+
}
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
throw (0, _error.generateFcrCoreClientError)(_error.FcrErrorModuleCode.ROOM_CHATROOM, _error.FcrErrorCode.UNDEFINED_ERROR, 'unknown local message type', new Error('unknown local message type'));
|
|
311
|
+
};
|
|
329
312
|
async sendMessage(message, progress) {
|
|
330
|
-
var _message$to2;
|
|
331
313
|
const msg = this._convertFcrChatRoomSendBaseMessageToAgoraChatMessage(message, progress);
|
|
332
314
|
const sendMsgRes = await this.conn.send(msg);
|
|
333
315
|
const localUserInfo = this._scene.getUser(this._scene.getLocalUser().getLocalUserId());
|
|
334
|
-
const res =
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
316
|
+
const res = {
|
|
317
|
+
...(message.type === _type.FcrChatRoomMessageType.Text ? {
|
|
318
|
+
content: message.content
|
|
319
|
+
} :
|
|
320
|
+
// @ts-ignore
|
|
321
|
+
{
|
|
322
|
+
url: sendMsgRes.message.url
|
|
323
|
+
}),
|
|
341
324
|
from: (0, _user.convertRteUserToFcrUser)(localUserInfo, this._roomCache),
|
|
342
325
|
id: sendMsgRes.serverMsgId,
|
|
343
326
|
type: message.type,
|
|
344
327
|
properties: message.properties,
|
|
345
328
|
timestamp: Date.now(),
|
|
346
|
-
isPrivate: !!
|
|
347
|
-
}
|
|
329
|
+
isPrivate: !!message.to?.length
|
|
330
|
+
};
|
|
348
331
|
return res;
|
|
349
332
|
}
|
|
350
333
|
addObserver(observer) {
|
|
@@ -433,6 +416,4 @@ class FcrChatRoomControlImpl {
|
|
|
433
416
|
// });
|
|
434
417
|
// }
|
|
435
418
|
}
|
|
436
|
-
exports.FcrChatRoomControlImpl = FcrChatRoomControlImpl;
|
|
437
|
-
_FcrChatRoomControlImpl = FcrChatRoomControlImpl;
|
|
438
|
-
[_initProto] = _applyDecs(_FcrChatRoomControlImpl, [[_imports.trace, 2, "join"], [_imports.trace, 2, "getConnectionState"], [_imports.trace, 2, "leave"], [_sendMessageDecs, 2, "sendMessage"], [_imports.trace, 2, "addObserver"], [_imports.trace, 2, "removeObserver"]], []).e;
|
|
419
|
+
exports.FcrChatRoomControlImpl = FcrChatRoomControlImpl;
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
require("core-js/modules/es.symbol.description.js");
|
|
4
|
-
require("core-js/modules/es.error.cause.js");
|
|
5
3
|
require("core-js/modules/es.array.push.js");
|
|
6
4
|
require("core-js/modules/esnext.function.metadata.js");
|
|
7
5
|
require("core-js/modules/esnext.map.delete-all.js");
|
|
@@ -19,16 +17,12 @@ require("core-js/modules/esnext.map.reduce.js");
|
|
|
19
17
|
require("core-js/modules/esnext.map.some.js");
|
|
20
18
|
require("core-js/modules/esnext.map.update.js");
|
|
21
19
|
require("core-js/modules/esnext.symbol.metadata.js");
|
|
22
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
23
20
|
Object.defineProperty(exports, "__esModule", {
|
|
24
21
|
value: true
|
|
25
22
|
});
|
|
26
23
|
exports.FcrAbilityControlImpl = void 0;
|
|
27
|
-
require("core-js/modules/web.dom-collections.iterator.js");
|
|
28
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
29
24
|
var _imports = require("../../imports");
|
|
30
25
|
var _logger = require("../../utilities/logger");
|
|
31
|
-
var _FcrAbilityControlImpl;
|
|
32
26
|
let _initProto;
|
|
33
27
|
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
28
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
@@ -40,15 +34,16 @@ function _checkInRHS(e) { if (Object(e) !== e) throw TypeError("right-hand side
|
|
|
40
34
|
* @internal
|
|
41
35
|
*/
|
|
42
36
|
class FcrAbilityControlImpl {
|
|
37
|
+
static #_ = (() => [_initProto] = _applyDecs(this, [[_imports.trace, 2, "isPlatformAbilitySupported"]], []).e)();
|
|
38
|
+
//@internal
|
|
39
|
+
logger = (() => (_initProto(this), (0, _logger.createLogger)({
|
|
40
|
+
prefix: 'FcrAbilityControlImpl'
|
|
41
|
+
})))();
|
|
43
42
|
constructor(_scene) {
|
|
44
|
-
//@internal
|
|
45
|
-
(0, _defineProperty2.default)(this, "logger", (_initProto(this), (0, _logger.createLogger)({
|
|
46
|
-
prefix: 'FcrAbilityControlImpl'
|
|
47
|
-
})));
|
|
48
43
|
this._scene = _scene;
|
|
49
44
|
}
|
|
50
45
|
getPlatformAbility(ability) {
|
|
51
|
-
const platforms = this._scene.getScenePropertiesByKeyPath(
|
|
46
|
+
const platforms = this._scene.getScenePropertiesByKeyPath(`setting.ability.${ability}`);
|
|
52
47
|
if (!Array.isArray(platforms)) {
|
|
53
48
|
return [];
|
|
54
49
|
}
|
|
@@ -64,6 +59,4 @@ class FcrAbilityControlImpl {
|
|
|
64
59
|
return platforms.includes(platform);
|
|
65
60
|
}
|
|
66
61
|
}
|
|
67
|
-
exports.FcrAbilityControlImpl = FcrAbilityControlImpl;
|
|
68
|
-
_FcrAbilityControlImpl = FcrAbilityControlImpl;
|
|
69
|
-
[_initProto] = _applyDecs(_FcrAbilityControlImpl, [[_imports.trace, 2, "isPlatformAbilitySupported"]], []).e;
|
|
62
|
+
exports.FcrAbilityControlImpl = FcrAbilityControlImpl;
|
|
@@ -3,7 +3,8 @@ export declare enum FcrAbility {
|
|
|
3
3
|
RoleHost = "role:host",
|
|
4
4
|
RoomDetail = "room:detail",
|
|
5
5
|
Live = "live",
|
|
6
|
-
Interpreter = "interpreter"
|
|
6
|
+
Interpreter = "interpreter",
|
|
7
|
+
Annotation = "annotation"
|
|
7
8
|
}
|
|
8
9
|
export interface FcrAbilityControl {
|
|
9
10
|
isAbilitySupported(ability: FcrAbility): boolean;
|
|
@@ -9,5 +9,6 @@ let FcrAbility = exports.FcrAbility = /*#__PURE__*/function (FcrAbility) {
|
|
|
9
9
|
FcrAbility["RoomDetail"] = "room:detail";
|
|
10
10
|
FcrAbility["Live"] = "live";
|
|
11
11
|
FcrAbility["Interpreter"] = "interpreter";
|
|
12
|
+
FcrAbility["Annotation"] = "annotation";
|
|
12
13
|
return FcrAbility;
|
|
13
14
|
}({});
|