fcr-core 3.8.1 → 3.9.0-alpha
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-connector/type.d.ts +40 -0
- package/lib/{chat-connection → chat-connector}/type.js +1 -1
- package/lib/engine/index.d.ts +10 -11
- package/lib/engine/index.js +63 -72
- package/lib/engine/type.d.ts +96 -0
- package/lib/engine/type.js +5 -0
- package/lib/imports.d.ts +7 -4
- package/lib/imports.js +30 -4
- package/lib/index.d.ts +3 -2
- package/lib/index.js +21 -2
- package/lib/media-control/desktop.js +12 -12
- package/lib/media-control/mobile.js +4 -0
- package/lib/media-control/type.d.ts +32 -33
- package/lib/monitor-control/index.js +3 -3
- package/lib/peer-session/index.js +14 -14
- package/lib/peer-session/type.d.ts +1 -1
- package/lib/plugins/chat/chatroom.js +417 -0
- package/lib/{chat-connection → plugins/chat}/config.d.ts +1 -0
- package/lib/{room-control/chatroom-control → plugins/chat}/config.js +2 -1
- package/lib/plugins/chat/connector.d.ts +38 -0
- package/lib/{chat-connection/index.js → plugins/chat/connector.js} +181 -61
- package/lib/room-control/ability-control/index.js +5 -4
- package/lib/room-control/ability-control/type.d.ts +5 -1
- package/lib/room-control/ability-control/type.js +4 -0
- package/lib/room-control/chatroom-control/type.d.ts +44 -35
- package/lib/room-control/group-control/index.js +9 -9
- package/lib/room-control/index.js +37 -22
- package/lib/room-control/interpreter-control/index.js +7 -4
- package/lib/room-control/interpreter-control/room.js +3 -3
- package/lib/room-control/interpreter-control/types.d.ts +2 -2
- package/lib/room-control/join-before-host-waitingroom-control/index.js +3 -3
- package/lib/room-control/mainroom-control/index.js +15 -13
- package/lib/room-control/privilege-control/index.js +39 -24
- package/lib/room-control/privilege-control/type.d.ts +15 -15
- package/lib/room-control/room-connector-control/index.js +7 -5
- package/lib/room-control/room-connector-control/type.d.ts +1 -1
- package/lib/room-control/room-control-factory.d.ts +3 -3
- package/lib/room-control/room-control-factory.js +7 -7
- package/lib/room-control/room-session/index.js +17 -15
- package/lib/room-control/room-session/type.d.ts +3 -3
- package/lib/room-control/sharing-control/index.js +13 -7
- package/lib/room-control/stream-control/index.js +18 -16
- package/lib/room-control/stream-control/type.d.ts +5 -5
- package/lib/room-control/stt-control/index.js +38 -31
- package/lib/room-control/type.d.ts +19 -19
- package/lib/room-control/user-control/index.js +20 -22
- package/lib/room-control/user-control/type.d.ts +1 -1
- package/lib/room-control/waitingroom-control/index.js +11 -11
- package/lib/room-control/whiteboard-control-v1/board-window.d.ts +21 -20
- package/lib/room-control/whiteboard-control-v1/board-window.js +27 -8
- package/lib/room-control/whiteboard-control-v1/factory.js +1 -1
- package/lib/room-control/whiteboard-control-v1/index.js +26 -18
- package/lib/room-control/whiteboard-control-v1/type.d.ts +26 -25
- package/lib/room-control/whiteboard-control-v1/type.js +1 -0
- package/lib/room-control/whiteboard-control-v2/annotation-control/control.d.ts +15 -6
- package/lib/room-control/whiteboard-control-v2/annotation-control/control.js +39 -5
- package/lib/room-control/whiteboard-control-v2/annotation-control/factory.d.ts +4 -5
- package/lib/room-control/whiteboard-control-v2/annotation-control/factory.js +6 -5
- package/lib/room-control/whiteboard-control-v2/annotation-control/type.d.ts +7 -1
- package/lib/room-control/whiteboard-control-v2/base/index.d.ts +9 -8
- package/lib/room-control/whiteboard-control-v2/base/index.js +84 -42
- package/lib/room-control/whiteboard-control-v2/base/main-window.d.ts +16 -15
- package/lib/room-control/whiteboard-control-v2/base/main-window.js +23 -4
- package/lib/room-control/whiteboard-control-v2/type.d.ts +17 -17
- package/lib/room-control/whiteboard-control-v2/whiteboard-control/control.d.ts +12 -6
- package/lib/room-control/whiteboard-control-v2/whiteboard-control/control.js +64 -18
- package/lib/room-control/whiteboard-control-v2/whiteboard-control/factory.d.ts +2 -2
- package/lib/room-control/whiteboard-control-v2/whiteboard-control/factory.js +10 -10
- package/lib/room-control/whiteboard-control-v2/whiteboard-control/type.d.ts +1 -1
- package/lib/room-router/index.js +10 -7
- package/lib/room-router/type.d.ts +1 -1
- package/lib/schema.d.ts +24 -46
- package/lib/schema.js +1 -2
- package/lib/service/api.d.ts +5 -3
- package/lib/service/api.js +17 -12
- package/lib/type.d.ts +64 -45
- package/lib/type.js +76 -11
- package/lib/utilities/abortable-retry.d.ts +38 -0
- package/lib/utilities/abortable-retry.js +61 -0
- package/lib/utilities/dual-video-stream-config.d.ts +6 -0
- package/lib/utilities/dual-video-stream-config.js +25 -0
- package/lib/utilities/error-helpers.d.ts +10 -9
- package/lib/utilities/error-helpers.js +12 -11
- package/lib/utilities/error.d.ts +4 -40
- package/lib/utilities/error.js +20 -77
- package/lib/utilities/join-helper.js +2 -2
- package/lib/utilities/logger.d.ts +2 -2
- package/lib/utilities/logger.js +6 -25
- package/lib/utilities/package-info.d.ts +1 -2
- package/lib/utilities/package-info.js +4 -8
- package/lib/utilities/parameters.js +88 -15
- package/lib/utilities/validate-params.js +1 -1
- package/lib/utilities/video-encoder-config.d.ts +9 -0
- package/lib/utilities/video-encoder-config.js +109 -0
- package/lib-es/base-session.js +1 -0
- package/lib-es/chat-connector/type.js +6 -0
- package/lib-es/engine/index.js +412 -0
- package/lib-es/engine/type.js +1 -0
- package/lib-es/imports.js +59 -0
- package/lib-es/index.js +8 -0
- package/lib-es/media-control/desktop.js +172 -0
- package/lib-es/media-control/mobile.js +198 -0
- package/lib-es/media-control/type.js +6 -0
- package/lib-es/monitor-control/index.js +46 -0
- package/lib-es/monitor-control/type.js +1 -0
- package/lib-es/peer-session/index.js +279 -0
- package/lib-es/peer-session/type.js +1 -0
- package/lib-es/plugins/chat/chatroom.js +409 -0
- package/{lib/chat-connection → lib-es/plugins/chat}/config.js +5 -9
- package/lib-es/plugins/chat/connector.js +269 -0
- package/lib-es/plugins/electron-rtc-plugin.js +1 -0
- package/lib-es/plugins/rtm-plugin.js +1 -0
- package/lib-es/plugins/web-rtc-plugin.js +1 -0
- package/lib-es/room-control/ability-control/index.js +58 -0
- package/lib-es/room-control/ability-control/type.js +15 -0
- package/lib-es/room-control/chatroom-control/type.js +12 -0
- package/lib-es/room-control/group-control/index.js +256 -0
- package/lib-es/room-control/helpers/constants.js +92 -0
- package/lib-es/room-control/helpers/index.js +20 -0
- package/lib-es/room-control/helpers/validation-helper.js +46 -0
- package/lib-es/room-control/index.js +623 -0
- package/lib-es/room-control/interpreter-control/index.js +172 -0
- package/lib-es/room-control/interpreter-control/room.js +28 -0
- package/lib-es/room-control/interpreter-control/types.js +26 -0
- package/lib-es/room-control/join-before-host-waitingroom-control/index.js +29 -0
- package/lib-es/room-control/mainroom-control/index.js +248 -0
- package/lib-es/room-control/privilege-control/helper.js +97 -0
- package/lib-es/room-control/privilege-control/index.js +339 -0
- package/lib-es/room-control/privilege-control/type.js +159 -0
- package/lib-es/room-control/room-connector-control/index.js +182 -0
- package/lib-es/room-control/room-connector-control/type.js +28 -0
- package/lib-es/room-control/room-control-factory.js +77 -0
- package/lib-es/room-control/room-session/index.js +292 -0
- package/lib-es/room-control/room-session/type.js +1 -0
- package/lib-es/room-control/shared-cache.js +47 -0
- package/lib-es/room-control/sharing-control/index.js +307 -0
- package/lib-es/room-control/sharing-control/type.js +16 -0
- package/lib-es/room-control/stream-control/index.js +536 -0
- package/lib-es/room-control/stream-control/type.js +1 -0
- package/lib-es/room-control/stt-control/de-compress-gzip.js +33 -0
- package/lib-es/room-control/stt-control/index.js +350 -0
- package/lib-es/room-control/stt-control/type.js +10 -0
- package/lib-es/room-control/type.js +30 -0
- package/lib-es/room-control/user-control/index.js +344 -0
- package/lib-es/room-control/user-control/type.js +21 -0
- package/lib-es/room-control/waitingroom-control/index.js +68 -0
- package/lib-es/room-control/whiteboard-control/enum.js +18 -0
- package/lib-es/room-control/whiteboard-control/type.js +10 -0
- package/lib-es/room-control/whiteboard-control/utils.js +13 -0
- package/lib-es/room-control/whiteboard-control-v1/board-subwindow.js +18 -0
- package/lib-es/room-control/whiteboard-control-v1/board-window.js +573 -0
- package/lib-es/room-control/whiteboard-control-v1/enum.js +157 -0
- package/lib-es/room-control/whiteboard-control-v1/factory.js +12 -0
- package/lib-es/room-control/whiteboard-control-v1/index.js +427 -0
- package/lib-es/room-control/whiteboard-control-v1/mount-manager.js +6 -0
- package/lib-es/room-control/whiteboard-control-v1/type.js +8 -0
- package/lib-es/room-control/whiteboard-control-v1/utils.js +273 -0
- package/lib-es/room-control/whiteboard-control-v2/annotation-control/control.js +76 -0
- package/lib-es/room-control/whiteboard-control-v2/annotation-control/factory.js +37 -0
- package/lib-es/room-control/whiteboard-control-v2/annotation-control/type.js +1 -0
- package/lib-es/room-control/whiteboard-control-v2/base/index.js +347 -0
- package/lib-es/room-control/whiteboard-control-v2/base/main-window.js +269 -0
- package/lib-es/room-control/whiteboard-control-v2/constant.js +9 -0
- package/lib-es/room-control/whiteboard-control-v2/enum.js +28 -0
- package/lib-es/room-control/whiteboard-control-v2/type.js +1 -0
- package/lib-es/room-control/whiteboard-control-v2/utils.js +92 -0
- package/lib-es/room-control/whiteboard-control-v2/whiteboard-control/control.js +204 -0
- package/lib-es/room-control/whiteboard-control-v2/whiteboard-control/factory.js +61 -0
- package/lib-es/room-control/whiteboard-control-v2/whiteboard-control/type.js +1 -0
- package/lib-es/room-router/index.js +263 -0
- package/lib-es/room-router/type.js +5 -0
- package/lib-es/schema.js +231 -0
- package/lib-es/service/api.js +1211 -0
- package/lib-es/service/type.js +1 -0
- package/lib-es/type.js +222 -0
- package/lib-es/utilities/abortable-retry.js +54 -0
- package/lib-es/utilities/cmd.js +1 -0
- package/lib-es/utilities/collection.js +64 -0
- package/lib-es/utilities/dual-video-stream-config.js +19 -0
- package/lib-es/utilities/error-helpers.js +224 -0
- package/lib-es/utilities/error.js +43 -0
- package/lib-es/utilities/join-helper.js +219 -0
- package/lib-es/utilities/logger.js +7 -0
- package/lib-es/utilities/package-info.js +5 -0
- package/lib-es/utilities/parameters.js +106 -0
- package/lib-es/utilities/retry-helpers.js +66 -0
- package/lib-es/utilities/shared-storage.js +31 -0
- package/lib-es/utilities/stream.js +18 -0
- package/lib-es/utilities/user.js +30 -0
- package/lib-es/utilities/validate-params.js +8 -0
- package/lib-es/utilities/video-encoder-config.js +103 -0
- package/package.json +11 -10
- package/lib/chat-connection/index.d.ts +0 -24
- package/lib/chat-connection/type.d.ts +0 -17
- package/lib/plugins/chatroom.js +0 -454
- package/lib/room-control/chatroom-control/config.d.ts +0 -51
- package/lib/utilities/storage.d.ts +0 -8
- package/lib/utilities/storage.js +0 -33
- /package/lib/plugins/{chatroom.d.ts → chat/chatroom.d.ts} +0 -0
|
@@ -0,0 +1,623 @@
|
|
|
1
|
+
import "core-js/modules/es.array.push.js";
|
|
2
|
+
import "core-js/modules/esnext.function.metadata.js";
|
|
3
|
+
import "core-js/modules/esnext.map.delete-all.js";
|
|
4
|
+
import "core-js/modules/esnext.map.emplace.js";
|
|
5
|
+
import "core-js/modules/esnext.map.every.js";
|
|
6
|
+
import "core-js/modules/esnext.map.filter.js";
|
|
7
|
+
import "core-js/modules/esnext.map.find.js";
|
|
8
|
+
import "core-js/modules/esnext.map.find-key.js";
|
|
9
|
+
import "core-js/modules/esnext.map.includes.js";
|
|
10
|
+
import "core-js/modules/esnext.map.key-of.js";
|
|
11
|
+
import "core-js/modules/esnext.map.map-keys.js";
|
|
12
|
+
import "core-js/modules/esnext.map.map-values.js";
|
|
13
|
+
import "core-js/modules/esnext.map.merge.js";
|
|
14
|
+
import "core-js/modules/esnext.map.reduce.js";
|
|
15
|
+
import "core-js/modules/esnext.map.some.js";
|
|
16
|
+
import "core-js/modules/esnext.map.update.js";
|
|
17
|
+
import "core-js/modules/esnext.symbol.metadata.js";
|
|
18
|
+
let _initProto, _joinDecs, _updateRoomPropertiesDecs, _updateIncrementRoomPropertiesDecs, _deleteRoomPropertiesDecs, _startCloudRecordingDecs, _startLiveStreamingDecs, _updateLiveStreamingLayoutDecs, _sendRoomMessageDecs;
|
|
19
|
+
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)]; } }; }
|
|
20
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
21
|
+
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); }
|
|
22
|
+
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; }
|
|
23
|
+
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; }
|
|
24
|
+
// Core SDK imports
|
|
25
|
+
import { AgoraObservable, jsonstring, to, trace } from '../imports';
|
|
26
|
+
|
|
27
|
+
// Service and API imports
|
|
28
|
+
|
|
29
|
+
// Type definitions
|
|
30
|
+
import { FcrLiveStreamingLayoutType, FcrLiveStreamingState, FcrRecordingState, FcrReturnCode, FcrUserRole, FcrUserRoleToStringMap } from '../type';
|
|
31
|
+
|
|
32
|
+
// Room control types and interfaces
|
|
33
|
+
import { FcrRoomType } from './type';
|
|
34
|
+
|
|
35
|
+
// Control implementations
|
|
36
|
+
import { FcrAbilityControlImpl } from './ability-control';
|
|
37
|
+
import { FcrPrivilegeControlImpl } from './privilege-control';
|
|
38
|
+
import { FcrRoomConnectorControlImpl } from './room-connector-control';
|
|
39
|
+
import { FcrRoomSessionControlImpl } from './room-session';
|
|
40
|
+
import { FcrSharingControlImpl } from './sharing-control';
|
|
41
|
+
import { FcrStreamControlImpl } from './stream-control';
|
|
42
|
+
import { FcrUserControlImpl } from './user-control';
|
|
43
|
+
// Error handling and utilities
|
|
44
|
+
import { ErrorModuleCode } from '../imports';
|
|
45
|
+
import { convertToStructure } from '../utilities/collection';
|
|
46
|
+
import { handleRequestError } from '../utilities/error';
|
|
47
|
+
import { createLogger } from '../utilities/logger';
|
|
48
|
+
|
|
49
|
+
// Core state
|
|
50
|
+
import { FcrConnectionState } from '..';
|
|
51
|
+
|
|
52
|
+
// Helpers and utilities
|
|
53
|
+
import { ControllerType } from '../utilities/error-helpers';
|
|
54
|
+
import { FcrJoinHelper, LIVE_STREAMING_STATE_VALUES, liveStreamingErrorHelper, RECORDING_STATE_VALUES, RESPONSE_CODES, ROOM_CONTROL_CONSTANTS, ROOM_MESSAGE_COMMANDS, ROOM_STATE_VALUES, roomControlErrorHelper, validateControllerInitialized, validateJoinRoomPreconditions, validateRoomJoined } from './helpers';
|
|
55
|
+
import { FcrSttControlImpl } from './stt-control';
|
|
56
|
+
/**
|
|
57
|
+
* 房间控制基础实现类
|
|
58
|
+
*
|
|
59
|
+
* 负责管理房间的生命周期,包括加入、离开、状态管理等核心功能。
|
|
60
|
+
* 提供统一的房间控制接口,管理各个子控制器的初始化和销毁。
|
|
61
|
+
*
|
|
62
|
+
* @internal
|
|
63
|
+
*/
|
|
64
|
+
export class FcrBaseRoomControlImpl {
|
|
65
|
+
static {
|
|
66
|
+
[_initProto] = _applyDecs(this, [[trace, 2, "getSyncTimestamp"], [trace, 2, "getRoomInfo"], [trace, 2, "getRoomSchedule"], [_joinDecs, 2, "join"], [trace, 2, "leave"], [trace, 2, "start"], [trace, 2, "end"], [trace, 2, "close"], [trace, 2, "getRoomState"], [trace, 2, "getRoomProperties"], [trace, 2, "getRoomPropertiesByKeyPath"], [_updateRoomPropertiesDecs, 2, "updateRoomProperties"], [_updateIncrementRoomPropertiesDecs, 2, "updateIncrementRoomProperties"], [_deleteRoomPropertiesDecs, 2, "deleteRoomProperties"], [_startCloudRecordingDecs, 2, "startCloudRecording"], [trace, 2, "pauseCloudRecording"], [trace, 2, "resumeCloudRecording"], [trace, 2, "stopCloudRecording"], [trace, 2, "getLiveStreamingState"], [trace, 2, "getLiveStreamingConfig"], [_startLiveStreamingDecs, 2, "startLiveStreaming"], [_updateLiveStreamingLayoutDecs, 2, "updateLiveStreamingLayout"], [trace, 2, "stopLiveStreaming"], [trace, 2, "getCloudRecordingState"], [_sendRoomMessageDecs, 2, "sendRoomMessage"]], []).e;
|
|
67
|
+
}
|
|
68
|
+
//@internal
|
|
69
|
+
[(_joinDecs = trace(['options']), _updateRoomPropertiesDecs = trace(['properties', 'cause']), _updateIncrementRoomPropertiesDecs = trace(['increments', 'cause']), _deleteRoomPropertiesDecs = trace(['properties', 'cause']), _startCloudRecordingDecs = trace(['config']), _startLiveStreamingDecs = trace(['data']), _updateLiveStreamingLayoutDecs = trace(['layoutType']), _sendRoomMessageDecs = trace(['payload', 'guaranteedDelivery']), "logger")] = (_initProto(this), createLogger({
|
|
70
|
+
prefix: 'FcrBaseRoomControlImpl'
|
|
71
|
+
}));
|
|
72
|
+
_observable = new AgoraObservable();
|
|
73
|
+
_joinRoomSuccess = false;
|
|
74
|
+
_joining = false;
|
|
75
|
+
_joinState = ROOM_CONTROL_CONSTANTS.JOIN_STATE.CANCELED;
|
|
76
|
+
constructor(_engine, _scene, _api, _config, _roomType, _chatConnection, _sharedCache, _chatRoomControl) {
|
|
77
|
+
this._engine = _engine;
|
|
78
|
+
this._scene = _scene;
|
|
79
|
+
this._api = _api;
|
|
80
|
+
this._config = _config;
|
|
81
|
+
this._roomType = _roomType;
|
|
82
|
+
this._chatConnection = _chatConnection;
|
|
83
|
+
this._sharedCache = _sharedCache;
|
|
84
|
+
this._chatRoomControl = _chatRoomControl;
|
|
85
|
+
// 初始化 FcrJoinHelper
|
|
86
|
+
const {
|
|
87
|
+
userId
|
|
88
|
+
} = this._engine.getConfig();
|
|
89
|
+
this._joinHelper = new FcrJoinHelper(userId, this._scene, this._api);
|
|
90
|
+
this._engineObserver = {
|
|
91
|
+
onConnectionStateUpdated: state => {
|
|
92
|
+
if (state === FcrConnectionState.ABORTED) {
|
|
93
|
+
this._joinState = ROOM_CONTROL_CONSTANTS.JOIN_STATE.CANCELED;
|
|
94
|
+
this._cleanup();
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
this._sceneObserver = {
|
|
99
|
+
onJoinSceneSuccess: (sceneId, localUser) => {
|
|
100
|
+
this._joinRoomSuccess = true;
|
|
101
|
+
this._chatRoomControl?.join();
|
|
102
|
+
this._userControl = new FcrUserControlImpl(this._scene, this._api, this._sharedCache);
|
|
103
|
+
this._streamControl = new FcrStreamControlImpl(this._engine, this._scene, this._api, this._sharedCache);
|
|
104
|
+
this._roomSessionControl = new FcrRoomSessionControlImpl(this, this._api, localUser.getLocalUserId());
|
|
105
|
+
this._privilegeControl = new FcrPrivilegeControlImpl(this._engine, this._scene, this._api, this._sharedCache);
|
|
106
|
+
this._roomConnectorControl = new FcrRoomConnectorControlImpl(this._scene, this._engine, this._api);
|
|
107
|
+
this._abilityControl = new FcrAbilityControlImpl(this._scene);
|
|
108
|
+
if (this._streamControl && !this.sharingControl &&
|
|
109
|
+
// TODO: 确认是否需要限制在主房间
|
|
110
|
+
this._roomType === FcrRoomType.Mainroom) {
|
|
111
|
+
this.logger.info('join scene success, start create sharing control');
|
|
112
|
+
this.sharingControl = new FcrSharingControlImpl(this._scene, this._api, this._engine, this._privilegeControl, this._streamControl, this._sharedCache, this._userControl);
|
|
113
|
+
}
|
|
114
|
+
this._sttControl = new FcrSttControlImpl(this._scene, this._api, this._sharedCache);
|
|
115
|
+
this._observable.notifyObservers('onJoinRoomSuccess', sceneId);
|
|
116
|
+
},
|
|
117
|
+
// onJoinSceneFailure: (sceneId, error) => {
|
|
118
|
+
// this._observable.notifyObservers(
|
|
119
|
+
// 'onJoinRoomFailure',
|
|
120
|
+
// sceneId,
|
|
121
|
+
// generateFcrCoreClientError(
|
|
122
|
+
// ErrorModuleCode.ROOM,
|
|
123
|
+
// FcrErrorCode.NOT_JOINED_ROOM,
|
|
124
|
+
// 'join room failed',
|
|
125
|
+
// error,
|
|
126
|
+
// ),
|
|
127
|
+
// );
|
|
128
|
+
// },
|
|
129
|
+
onSceneMessageReceived: (sceneId, message) => {
|
|
130
|
+
this._observable.notifyObservers('onRoomMessageReceived', sceneId, message);
|
|
131
|
+
const payload = message.payload;
|
|
132
|
+
if (message.cmd === ROOM_MESSAGE_COMMANDS.ROOM_ROUTE_SWITCH) {
|
|
133
|
+
const localUserRole = this._userControl?.getLocalUser().userRole;
|
|
134
|
+
if (localUserRole && payload.targetRoles.includes(FcrUserRoleToStringMap[localUserRole])) {
|
|
135
|
+
this._observable.notifyObservers('onRoomRouteSwitched', {
|
|
136
|
+
targetRouting: {
|
|
137
|
+
roomId: payload.toRoom.roomUuid,
|
|
138
|
+
roomType: payload.toRoom.roomType,
|
|
139
|
+
isJoined: false
|
|
140
|
+
},
|
|
141
|
+
operatorUser: this._userControl?.getUser(message.senderId)
|
|
142
|
+
});
|
|
143
|
+
this.leave();
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
onScenePropertiesUpdated: async (sceneId, event) => {
|
|
148
|
+
if (event.cause?.cmd === ROOM_MESSAGE_COMMANDS.CLOUD_RECORDING) {
|
|
149
|
+
const {
|
|
150
|
+
state,
|
|
151
|
+
ready,
|
|
152
|
+
onhold
|
|
153
|
+
} = this._scene.getSceneProperties().record;
|
|
154
|
+
const recordState = this._formatRecordingState(state, ready, onhold);
|
|
155
|
+
this._observable.notifyObservers('onCloudRecordingStateUpdated', sceneId, recordState);
|
|
156
|
+
}
|
|
157
|
+
if (event.cause?.cmd === ROOM_MESSAGE_COMMANDS.ROOM_STATE_UPDATE) {
|
|
158
|
+
const schedule = event.changedProperties.schedule;
|
|
159
|
+
if (schedule.state === ROOM_STATE_VALUES.ENDED) {
|
|
160
|
+
this._joinState = ROOM_CONTROL_CONSTANTS.JOIN_STATE.CANCELED;
|
|
161
|
+
this._cleanup();
|
|
162
|
+
}
|
|
163
|
+
this._observable.notifyObservers('onRoomStateUpdated', sceneId, schedule.state);
|
|
164
|
+
}
|
|
165
|
+
if (event.cause?.cmd === ROOM_MESSAGE_COMMANDS.ROOM_PROPERTIES_UPDATE) {
|
|
166
|
+
const changedProperties = {};
|
|
167
|
+
for (const key in event.changedProperties) {
|
|
168
|
+
if (key.startsWith('flexProps')) {
|
|
169
|
+
changedProperties[key] = event.changedProperties[key];
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
if (Object.keys(changedProperties).length > 0) {
|
|
173
|
+
const structure = convertToStructure(changedProperties);
|
|
174
|
+
this._observable.notifyObservers('onRoomPropertiesUpdated', sceneId, {
|
|
175
|
+
...event,
|
|
176
|
+
changedProperties: structure['flexProps']
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
if (event.cause?.cmd === ROOM_MESSAGE_COMMANDS.LIVE_STREAMING_UPDATE) {
|
|
181
|
+
let liveStreamingState = FcrLiveStreamingState.STOPPED;
|
|
182
|
+
let state = this._scene.getScenePropertiesByKeyPath('live.state');
|
|
183
|
+
let pageUrl = this._scene.getScenePropertiesByKeyPath('live.pageUrl');
|
|
184
|
+
const reason = event.cause?.data?.reason;
|
|
185
|
+
if (state === LIVE_STREAMING_STATE_VALUES.STARTED) {
|
|
186
|
+
liveStreamingState = FcrLiveStreamingState.STARTED;
|
|
187
|
+
}
|
|
188
|
+
if (state === LIVE_STREAMING_STATE_VALUES.STOPPED_ALT) {
|
|
189
|
+
liveStreamingState = FcrLiveStreamingState.STOPPED;
|
|
190
|
+
}
|
|
191
|
+
this._observable.notifyObservers('onLiveStreamingStateUpdated', sceneId, liveStreamingState, pageUrl, reason);
|
|
192
|
+
}
|
|
193
|
+
},
|
|
194
|
+
onScenePropertiesDeleted: (sceneId, event) => {
|
|
195
|
+
if (event.cause?.cmd === ROOM_MESSAGE_COMMANDS.ROOM_PROPERTIES_UPDATE) {
|
|
196
|
+
this._observable.notifyObservers('onRoomPropertiesDeleted', sceneId, event);
|
|
197
|
+
}
|
|
198
|
+
},
|
|
199
|
+
onNetworkQualityUpdated: (sceneId, event) => {
|
|
200
|
+
this._observable.notifyObservers('onNetworkQualityUpdated', sceneId, event);
|
|
201
|
+
},
|
|
202
|
+
onNetworkStatsUpdated: (sceneId, stats) => {
|
|
203
|
+
this._observable.notifyObservers('onNetworkStatsUpdated', sceneId, stats);
|
|
204
|
+
},
|
|
205
|
+
onUserPropertiesUpdated: (_, event) => {
|
|
206
|
+
if (event.cause?.cmd === ROOM_MESSAGE_COMMANDS.USER_KICK_OUT && event.modifiedUser.userId === this._scene.localUser.getLocalUserId()) {
|
|
207
|
+
this._joinState = ROOM_CONTROL_CONSTANTS.JOIN_STATE.CANCELED;
|
|
208
|
+
this._cleanup();
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* 获取字幕控制器
|
|
216
|
+
* @returns 字幕控制器实例
|
|
217
|
+
* @throws {FcrError} 如果控制器未初始化
|
|
218
|
+
*/
|
|
219
|
+
// @trace
|
|
220
|
+
getSttControl() {
|
|
221
|
+
validateControllerInitialized(this._sttControl, ControllerType.STT);
|
|
222
|
+
return this._sttControl;
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* 获取屏幕共享控制器
|
|
226
|
+
* @returns 屏幕共享控制器实例
|
|
227
|
+
* @throws {FcrError} 如果控制器未初始化
|
|
228
|
+
*/
|
|
229
|
+
// @trace
|
|
230
|
+
getSharingControl() {
|
|
231
|
+
validateControllerInitialized(this.sharingControl, ControllerType.SHARING);
|
|
232
|
+
return this.sharingControl;
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* 获取用户控制器
|
|
236
|
+
* @returns 用户控制器实例
|
|
237
|
+
* @throws {FcrError} 如果控制器未初始化
|
|
238
|
+
*/
|
|
239
|
+
// @trace
|
|
240
|
+
getUserControl() {
|
|
241
|
+
validateControllerInitialized(this._userControl, ControllerType.USER);
|
|
242
|
+
return this._userControl;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* 获取流控制器
|
|
247
|
+
* @returns 流控制器实例
|
|
248
|
+
* @throws {FcrError} 如果控制器未初始化
|
|
249
|
+
*/
|
|
250
|
+
// @trace
|
|
251
|
+
getStreamControl() {
|
|
252
|
+
validateControllerInitialized(this._streamControl, ControllerType.STREAM);
|
|
253
|
+
return this._streamControl;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* 获取房间会话控制器
|
|
258
|
+
* @returns 房间会话控制器实例
|
|
259
|
+
* @throws {FcrError} 如果控制器未初始化
|
|
260
|
+
*/
|
|
261
|
+
// @trace
|
|
262
|
+
getRoomSessionControl() {
|
|
263
|
+
validateControllerInitialized(this._roomSessionControl, ControllerType.ROOM_SESSION);
|
|
264
|
+
return this._roomSessionControl;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* 获取聊天室控制器
|
|
269
|
+
* @returns 聊天室控制器实例
|
|
270
|
+
* @throws {FcrError} 如果控制器未初始化
|
|
271
|
+
*/
|
|
272
|
+
// @trace
|
|
273
|
+
getChatRoomControl() {
|
|
274
|
+
validateControllerInitialized(this._chatRoomControl, ControllerType.CHAT_ROOM);
|
|
275
|
+
return this._chatRoomControl;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* 获取权限控制器
|
|
280
|
+
* @returns 权限控制器实例
|
|
281
|
+
* @throws {FcrError} 如果控制器未初始化
|
|
282
|
+
*/
|
|
283
|
+
// @trace
|
|
284
|
+
getPrivilegeControl() {
|
|
285
|
+
validateControllerInitialized(this._privilegeControl, ControllerType.PRIVILEGE);
|
|
286
|
+
return this._privilegeControl;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
// @trace
|
|
290
|
+
getRoomConnectorControl() {
|
|
291
|
+
validateControllerInitialized(this._roomConnectorControl, ControllerType.ROOM_CONNECTOR);
|
|
292
|
+
return this._roomConnectorControl;
|
|
293
|
+
}
|
|
294
|
+
getAbilityControl() {
|
|
295
|
+
validateControllerInitialized(this._abilityControl, ControllerType.ABILITY);
|
|
296
|
+
return this._abilityControl;
|
|
297
|
+
}
|
|
298
|
+
getSyncTimestamp() {
|
|
299
|
+
return this._scene.getSyncTimestamp();
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* 获取房间信息
|
|
304
|
+
*
|
|
305
|
+
* @returns 房间信息,如果未加入房间则返回 undefined
|
|
306
|
+
*/
|
|
307
|
+
getRoomInfo() {
|
|
308
|
+
const sceneInfo = this._scene.getSceneInfo();
|
|
309
|
+
const passwordInfo = this._scene.getScenePropertiesByKeyPath('security.password');
|
|
310
|
+
const userProperties = this._scene.getUserPropertiesByUserId(this._scene.localUser.getLocalUserId());
|
|
311
|
+
const shareLink = userProperties?.info?.shareLink;
|
|
312
|
+
const label = this._scene.getScenePropertiesByKeyPath('label');
|
|
313
|
+
return sceneInfo ? {
|
|
314
|
+
roomId: sceneInfo.sceneId,
|
|
315
|
+
roomName: sceneInfo.sceneName,
|
|
316
|
+
roomType: this._roomType,
|
|
317
|
+
password: passwordInfo?.payload?.text,
|
|
318
|
+
inviteLink: shareLink,
|
|
319
|
+
label
|
|
320
|
+
} : void 0;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
* 获取房间计划信息
|
|
325
|
+
*
|
|
326
|
+
* @returns 房间计划信息,包括开始时间、时长等
|
|
327
|
+
* @throws {FcrError} 如果未加入房间
|
|
328
|
+
*/
|
|
329
|
+
getRoomSchedule() {
|
|
330
|
+
validateRoomJoined(this._joinRoomSuccess, 'get schedule info');
|
|
331
|
+
const schedule = this._scene.getScenePropertiesByKeyPath('schedule');
|
|
332
|
+
return {
|
|
333
|
+
...schedule,
|
|
334
|
+
duration: schedule.duration ?? 0,
|
|
335
|
+
startTime: Math.floor((schedule.startTime ?? 0) / 1000)
|
|
336
|
+
};
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* 加入房间
|
|
340
|
+
*
|
|
341
|
+
* 支持两种加入方式:
|
|
342
|
+
* 1. 通过快照加入(适用于已有房间快照的场景)
|
|
343
|
+
* 2. 通过选项加入(需要进行CheckIn流程)
|
|
344
|
+
*
|
|
345
|
+
* @param options 加入房间的选项或快照
|
|
346
|
+
* @throws {FcrError} 加入失败时抛出错误
|
|
347
|
+
*/
|
|
348
|
+
async join(options) {
|
|
349
|
+
// 前置验证和状态设置
|
|
350
|
+
this._validateAndSetupJoinState();
|
|
351
|
+
try {
|
|
352
|
+
this._initializeJoinObservers();
|
|
353
|
+
await this._executeJoinProcess(options);
|
|
354
|
+
|
|
355
|
+
// 处理机器人用户的特殊逻辑
|
|
356
|
+
await this._handleRobotUserSetup(options);
|
|
357
|
+
return FcrReturnCode.SUCCESS;
|
|
358
|
+
} catch (error) {
|
|
359
|
+
this._cleanup();
|
|
360
|
+
// 处理加入失败
|
|
361
|
+
this._handleJoinFailure(error);
|
|
362
|
+
throw error;
|
|
363
|
+
} finally {
|
|
364
|
+
// 清理状态
|
|
365
|
+
this._joining = false;
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
/**
|
|
370
|
+
* 验证前置条件并设置加入状态
|
|
371
|
+
* @private
|
|
372
|
+
*/
|
|
373
|
+
_validateAndSetupJoinState() {
|
|
374
|
+
this._joinState = ROOM_CONTROL_CONSTANTS.JOIN_STATE.JOINING;
|
|
375
|
+
validateJoinRoomPreconditions(this._joinRoomSuccess, this._joining);
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
/**
|
|
379
|
+
* 初始化加入过程的观察者和状态
|
|
380
|
+
* @private
|
|
381
|
+
*/
|
|
382
|
+
_initializeJoinObservers() {
|
|
383
|
+
this._joining = true;
|
|
384
|
+
this._scene.addObserver(this._sceneObserver);
|
|
385
|
+
this._engine.addObserver(this._engineObserver);
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
/**
|
|
389
|
+
* 执行房间加入过程
|
|
390
|
+
* @private
|
|
391
|
+
*/
|
|
392
|
+
async _executeJoinProcess(options) {
|
|
393
|
+
const handleJoinAborted = this._createJoinAbortedHandler();
|
|
394
|
+
const [error] = await to(this._joinHelper.join(options, handleJoinAborted));
|
|
395
|
+
if (error) {
|
|
396
|
+
throw error;
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
/**
|
|
401
|
+
* 创建加入中止处理器
|
|
402
|
+
* @private
|
|
403
|
+
*/
|
|
404
|
+
_createJoinAbortedHandler() {
|
|
405
|
+
return () => {
|
|
406
|
+
if (this._joinState === ROOM_CONTROL_CONSTANTS.JOIN_STATE.CANCELED) {
|
|
407
|
+
this.logger.info('join is canceled');
|
|
408
|
+
this._cleanup();
|
|
409
|
+
const fcrError = roomControlErrorHelper.createOperationCanceledError('Joining');
|
|
410
|
+
this._observable.notifyObservers('onJoinRoomFailure', this._scene.sceneId, fcrError);
|
|
411
|
+
throw fcrError;
|
|
412
|
+
}
|
|
413
|
+
};
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
/**
|
|
417
|
+
* 处理机器人用户的特殊设置
|
|
418
|
+
* @private
|
|
419
|
+
*/
|
|
420
|
+
async _handleRobotUserSetup(options) {
|
|
421
|
+
if (options.userRole === FcrUserRole.ROBOT) {
|
|
422
|
+
const res = handleRequestError(() => this._api.setCloudRecordingReady(this._scene.sceneId), ErrorModuleCode.FCR_ROOM, 'set cloud recording ready failed');
|
|
423
|
+
this.logger.info(`set cloud recording ready, response: ${jsonstring(res)}`);
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
/**
|
|
428
|
+
* 处理加入失败的情况
|
|
429
|
+
* @private
|
|
430
|
+
*/
|
|
431
|
+
_handleJoinFailure(error) {
|
|
432
|
+
this.logger.error(`failed to join room: ${error.message}`);
|
|
433
|
+
this._observable.notifyObservers('onJoinRoomFailure', this._scene.sceneId, error);
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
/**
|
|
437
|
+
* 离开房间
|
|
438
|
+
*
|
|
439
|
+
* 清理所有资源,包括观察者、控制器实例等
|
|
440
|
+
*/
|
|
441
|
+
async leave() {
|
|
442
|
+
this._joinState = ROOM_CONTROL_CONSTANTS.JOIN_STATE.CANCELED;
|
|
443
|
+
await this._cleanup();
|
|
444
|
+
return FcrReturnCode.SUCCESS;
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
/**
|
|
448
|
+
* 开始房间
|
|
449
|
+
*
|
|
450
|
+
* 只有房间创建者或管理员才能调用此方法
|
|
451
|
+
*/
|
|
452
|
+
async start() {
|
|
453
|
+
await this._api.startRoom(this._scene.sceneId);
|
|
454
|
+
return FcrReturnCode.SUCCESS;
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
/**
|
|
458
|
+
* 结束房间
|
|
459
|
+
*
|
|
460
|
+
* 只有房间创建者或管理员才能调用此方法
|
|
461
|
+
*/
|
|
462
|
+
async end() {
|
|
463
|
+
await this._api.endRoom(this._scene.sceneId);
|
|
464
|
+
return FcrReturnCode.SUCCESS;
|
|
465
|
+
}
|
|
466
|
+
async close() {
|
|
467
|
+
await this._api.closeRoom(this._scene.sceneId);
|
|
468
|
+
return FcrReturnCode.SUCCESS;
|
|
469
|
+
}
|
|
470
|
+
getRoomState() {
|
|
471
|
+
return this._scene.getScenePropertiesByKeyPath('schedule.state');
|
|
472
|
+
}
|
|
473
|
+
getRoomProperties() {
|
|
474
|
+
return this._scene.getScenePropertiesByKeyPath('flexProps');
|
|
475
|
+
}
|
|
476
|
+
getRoomPropertiesByKeyPath(keyPath) {
|
|
477
|
+
return this._scene.getScenePropertiesByKeyPath('flexProps.' + keyPath);
|
|
478
|
+
}
|
|
479
|
+
async updateRoomProperties(properties, cause) {
|
|
480
|
+
await handleRequestError(() => this._api.updateRoomProperties({
|
|
481
|
+
roomId: this._scene.sceneId,
|
|
482
|
+
properties,
|
|
483
|
+
cause
|
|
484
|
+
}), ErrorModuleCode.FCR_ROOM, 'update room properties failed');
|
|
485
|
+
return FcrReturnCode.SUCCESS;
|
|
486
|
+
}
|
|
487
|
+
async updateIncrementRoomProperties(increments, cause) {
|
|
488
|
+
await handleRequestError(() => this._api.updateRoomProperties({
|
|
489
|
+
roomId: this._scene.sceneId,
|
|
490
|
+
increments,
|
|
491
|
+
cause
|
|
492
|
+
}), ErrorModuleCode.FCR_ROOM, 'update room properties failed');
|
|
493
|
+
return FcrReturnCode.SUCCESS;
|
|
494
|
+
}
|
|
495
|
+
async deleteRoomProperties(properties, cause) {
|
|
496
|
+
await handleRequestError(() => this._api.deleteRoomProperties({
|
|
497
|
+
roomId: this._scene.sceneId,
|
|
498
|
+
properties,
|
|
499
|
+
cause
|
|
500
|
+
}), ErrorModuleCode.FCR_ROOM, 'delete room rroperties failed');
|
|
501
|
+
return FcrReturnCode.SUCCESS;
|
|
502
|
+
}
|
|
503
|
+
async startCloudRecording(config) {
|
|
504
|
+
await handleRequestError(() => this._api.startCloudRecording(config, this._scene.sceneId), ErrorModuleCode.FCR_ROOM, 'start cloud recording failed');
|
|
505
|
+
return FcrReturnCode.SUCCESS;
|
|
506
|
+
}
|
|
507
|
+
async pauseCloudRecording() {
|
|
508
|
+
await handleRequestError(() => this._api.pauseCloudRecording(this._scene.sceneId), ErrorModuleCode.FCR_ROOM, 'pause cloud recording failed');
|
|
509
|
+
return FcrReturnCode.SUCCESS;
|
|
510
|
+
}
|
|
511
|
+
async resumeCloudRecording() {
|
|
512
|
+
await handleRequestError(() => this._api.resumeCloudRecording(this._scene.sceneId), ErrorModuleCode.FCR_ROOM, 'resume cloud recording failed');
|
|
513
|
+
return FcrReturnCode.SUCCESS;
|
|
514
|
+
}
|
|
515
|
+
async stopCloudRecording() {
|
|
516
|
+
await handleRequestError(() => this._api.stopCloudRecording(this._scene.sceneId), ErrorModuleCode.FCR_ROOM, 'stop cloud recording failed');
|
|
517
|
+
return FcrReturnCode.SUCCESS;
|
|
518
|
+
}
|
|
519
|
+
getLiveStreamingState() {
|
|
520
|
+
let liveStreamingState = this._scene.getScenePropertiesByKeyPath('live.state');
|
|
521
|
+
if (liveStreamingState === LIVE_STREAMING_STATE_VALUES.STARTED) {
|
|
522
|
+
return FcrLiveStreamingState.STARTED;
|
|
523
|
+
}
|
|
524
|
+
if (liveStreamingState === LIVE_STREAMING_STATE_VALUES.STOPPED_ALT) {
|
|
525
|
+
return FcrLiveStreamingState.STOPPED;
|
|
526
|
+
}
|
|
527
|
+
return FcrLiveStreamingState.STOPPED;
|
|
528
|
+
}
|
|
529
|
+
getLiveStreamingConfig() {
|
|
530
|
+
const res = this._scene.getScenePropertiesByKeyPath('live');
|
|
531
|
+
if (res) {
|
|
532
|
+
return {
|
|
533
|
+
pushStreamingUrl: res.streamUrl,
|
|
534
|
+
pullStreamingUrl: res.pageUrl,
|
|
535
|
+
pushStreamingKey: res.streamKey,
|
|
536
|
+
layoutType: res.layoutType
|
|
537
|
+
};
|
|
538
|
+
}
|
|
539
|
+
return {
|
|
540
|
+
pushStreamingUrl: '',
|
|
541
|
+
pullStreamingUrl: '',
|
|
542
|
+
pushStreamingKey: '',
|
|
543
|
+
layoutType: FcrLiveStreamingLayoutType.SPEAKER
|
|
544
|
+
};
|
|
545
|
+
}
|
|
546
|
+
async startLiveStreaming(data) {
|
|
547
|
+
await this._liveStreamingAction(() => this._api.startLiveStreaming(this._scene.sceneId, data), 'start live streaming failed');
|
|
548
|
+
return FcrReturnCode.SUCCESS;
|
|
549
|
+
}
|
|
550
|
+
async updateLiveStreamingLayout(layoutType) {
|
|
551
|
+
await this._liveStreamingAction(() => this._api.updateLiveStreamingLayout(this._scene.sceneId, layoutType), 'update live streaming layout failed');
|
|
552
|
+
return FcrReturnCode.SUCCESS;
|
|
553
|
+
}
|
|
554
|
+
async stopLiveStreaming() {
|
|
555
|
+
await this._liveStreamingAction(() => this._api.stopLiveStreaming(this._scene.sceneId), 'stop live streaming failed');
|
|
556
|
+
return FcrReturnCode.SUCCESS;
|
|
557
|
+
}
|
|
558
|
+
getCloudRecordingState() {
|
|
559
|
+
const {
|
|
560
|
+
state,
|
|
561
|
+
ready,
|
|
562
|
+
onhold
|
|
563
|
+
} = this._scene.getScenePropertiesByKeyPath('record');
|
|
564
|
+
return this._formatRecordingState(state, ready, onhold);
|
|
565
|
+
}
|
|
566
|
+
async sendRoomMessage(payload, guaranteedDelivery) {
|
|
567
|
+
try {
|
|
568
|
+
await this._scene.localUser.sendSceneMessage(payload, '101', guaranteedDelivery);
|
|
569
|
+
return FcrReturnCode.SUCCESS;
|
|
570
|
+
} catch (e) {
|
|
571
|
+
throw roomControlErrorHelper.createSendMessageError(e);
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
isHostKeyEnabled() {
|
|
575
|
+
return this._scene.getScenePropertiesByKeyPath('info.hasHostKey');
|
|
576
|
+
}
|
|
577
|
+
addObserver(observer) {
|
|
578
|
+
this._observable.addObserver(observer);
|
|
579
|
+
}
|
|
580
|
+
removeObserver(observer) {
|
|
581
|
+
this._observable.removeObserver(observer);
|
|
582
|
+
}
|
|
583
|
+
async _cleanup() {
|
|
584
|
+
this._scene.removeObserver(this._sceneObserver);
|
|
585
|
+
this._engine.removeObserver(this._engineObserver);
|
|
586
|
+
try {
|
|
587
|
+
return await Promise.all([this._chatRoomControl?.leave(), this.sharingControl?.getBoardControl().close(), this.sharingControl?.getAnnotationControl().close(), this._scene.leave()]);
|
|
588
|
+
} finally {
|
|
589
|
+
this._joinRoomSuccess = false;
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
_formatRecordingState(state, ready, onhold) {
|
|
593
|
+
let recordState = FcrRecordingState.Stopped;
|
|
594
|
+
if (state === RECORDING_STATE_VALUES.RECORDING) {
|
|
595
|
+
if (!ready) {
|
|
596
|
+
recordState = FcrRecordingState.Starting;
|
|
597
|
+
} else {
|
|
598
|
+
if (!onhold) {
|
|
599
|
+
recordState = FcrRecordingState.Started;
|
|
600
|
+
} else {
|
|
601
|
+
recordState = FcrRecordingState.Paused;
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
return recordState;
|
|
606
|
+
}
|
|
607
|
+
async _liveStreamingAction(action, errorMessage) {
|
|
608
|
+
try {
|
|
609
|
+
const {
|
|
610
|
+
code
|
|
611
|
+
} = await action();
|
|
612
|
+
if (code !== RESPONSE_CODES.SUCCESS) {
|
|
613
|
+
throw liveStreamingErrorHelper.createNetworkError(errorMessage);
|
|
614
|
+
}
|
|
615
|
+
} catch (error) {
|
|
616
|
+
throw liveStreamingErrorHelper.createNetworkError(errorMessage);
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
/**
|
|
621
|
+
* @internal
|
|
622
|
+
*/
|
|
623
|
+
export class FcrSubRoomControlImpl extends FcrBaseRoomControlImpl {}
|