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
|
@@ -1,21 +1,13 @@
|
|
|
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.symbol.metadata.js");
|
|
12
6
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
13
7
|
Object.defineProperty(exports, "__esModule", {
|
|
14
8
|
value: true
|
|
15
9
|
});
|
|
16
10
|
exports.FcrPeerSessionControlImpl = void 0;
|
|
17
|
-
require("core-js/modules/es.error.cause.js");
|
|
18
|
-
require("core-js/modules/es.json.stringify.js");
|
|
19
11
|
require("core-js/modules/esnext.map.delete-all.js");
|
|
20
12
|
require("core-js/modules/esnext.map.emplace.js");
|
|
21
13
|
require("core-js/modules/esnext.map.every.js");
|
|
@@ -30,17 +22,12 @@ require("core-js/modules/esnext.map.merge.js");
|
|
|
30
22
|
require("core-js/modules/esnext.map.reduce.js");
|
|
31
23
|
require("core-js/modules/esnext.map.some.js");
|
|
32
24
|
require("core-js/modules/esnext.map.update.js");
|
|
33
|
-
require("core-js/modules/web.dom-collections.iterator.js");
|
|
34
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
35
25
|
var _imports = require("../imports");
|
|
36
26
|
var _error = require("../utilities/error");
|
|
37
27
|
var _logger = require("../utilities/logger");
|
|
38
28
|
var _schema = require("../schema");
|
|
39
29
|
var _validateParams = _interopRequireDefault(require("../utilities/validate-params"));
|
|
40
|
-
|
|
41
|
-
let _initProto, _startPeerSessionDecs, _stopPeerSessionDecs, _acceptPeerSessionDecs, _rejectPeerSessionDecs, _ref;
|
|
42
|
-
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; }
|
|
43
|
-
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; }
|
|
30
|
+
let _initProto, _startPeerSessionDecs, _stopPeerSessionDecs, _acceptPeerSessionDecs, _rejectPeerSessionDecs;
|
|
44
31
|
function _applyDecs(e, t, r, n, o, a) { function i(e, t, r) { return function (n, o) { return r && r(n), e[t].call(n, o); }; } function c(e, t) { for (var r = 0; r < e.length; r++) e[r].call(t); return t; } function s(e, t, r, n) { if ("function" != typeof e && (n || void 0 !== e)) throw new TypeError(t + " must " + (r || "be") + " a function" + (n ? "" : " or undefined")); return e; } function applyDec(e, t, r, n, o, a, c, u, l, f, p, d, h) { function m(e) { if (!h(e)) throw new TypeError("Attempted to access private element on non-instance"); } var y, v = t[0], g = t[3], b = !u; if (!b) { r || Array.isArray(v) || (v = [v]); var w = {}, S = [], A = 3 === o ? "get" : 4 === o || d ? "set" : "value"; f ? (p || d ? w = { get: _setFunctionName(function () { return g(this); }, n, "get"), set: function (e) { t[4](this, e); } } : w[A] = g, p || _setFunctionName(w[A], n, 2 === o ? "" : A)) : p || (w = Object.getOwnPropertyDescriptor(e, n)); } for (var P = e, j = v.length - 1; j >= 0; j -= r ? 2 : 1) { var D = v[j], E = r ? v[j - 1] : void 0, I = {}, O = { kind: ["field", "accessor", "method", "getter", "setter", "class"][o], name: n, metadata: a, addInitializer: function (e, t) { if (e.v) throw Error("attempted to call addInitializer after decoration was finished"); s(t, "An initializer", "be", !0), c.push(t); }.bind(null, I) }; try { if (b) (y = s(D.call(E, P, O), "class decorators", "return")) && (P = y);else { var k, F; O.static = l, O.private = f, f ? 2 === o ? k = function (e) { return m(e), w.value; } : (o < 4 && (k = i(w, "get", m)), 3 !== o && (F = i(w, "set", m))) : (k = function (e) { return e[n]; }, (o < 2 || 4 === o) && (F = function (e, t) { e[n] = t; })); var N = O.access = { has: f ? h.bind() : function (e) { return n in e; } }; if (k && (N.get = k), F && (N.set = F), P = D.call(E, d ? { get: w.get, set: w.set } : w[A], O), d) { if ("object" == typeof P && P) (y = s(P.get, "accessor.get")) && (w.get = y), (y = s(P.set, "accessor.set")) && (w.set = y), (y = s(P.init, "accessor.init")) && S.push(y);else if (void 0 !== P) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0"); } else s(P, (p ? "field" : "method") + " decorators", "return") && (p ? S.push(P) : w[A] = P); } } finally { I.v = !0; } } return (p || d) && u.push(function (e, t) { for (var r = S.length - 1; r >= 0; r--) t = S[r].call(e, t); return t; }), p || b || (f ? d ? u.push(i(w, "get"), i(w, "set")) : u.push(2 === o ? w[A] : i.call.bind(w[A])) : Object.defineProperty(e, n, w)), P; } function u(e, t) { return Object.defineProperty(e, Symbol.metadata || Symbol.for("Symbol.metadata"), { configurable: !0, enumerable: !0, value: t }); } if (arguments.length >= 6) var l = a[Symbol.metadata || Symbol.for("Symbol.metadata")]; var f = Object.create(null == l ? null : l), p = function (e, t, r, n) { var o, a, i = [], s = function (t) { return _checkInRHS(t) === e; }, u = new Map(); function l(e) { e && i.push(c.bind(null, e)); } for (var f = 0; f < t.length; f++) { var p = t[f]; if (Array.isArray(p)) { var d = p[1], h = p[2], m = p.length > 3, y = 16 & d, v = !!(8 & d), g = 0 == (d &= 7), b = h + "/" + v; if (!g && !m) { var w = u.get(b); if (!0 === w || 3 === w && 4 !== d || 4 === w && 3 !== d) throw Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + h); u.set(b, !(d > 2) || d); } applyDec(v ? e : e.prototype, p, y, m ? "#" + h : _toPropertyKey(h), d, n, v ? a = a || [] : o = o || [], i, v, m, g, 1 === d, v && m ? s : r); } } return l(o), l(a), i; }(e, t, o, f); return r.length || u(e, f), { e: p, get c() { var t = []; return r.length && [u(applyDec(e, [r], n, e.name, 5, f, t), f), c.bind(null, t, e)]; } }; }
|
|
45
32
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
46
33
|
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
@@ -49,21 +36,23 @@ function _checkInRHS(e) { if (Object(e) !== e) throw TypeError("right-hand side
|
|
|
49
36
|
/**
|
|
50
37
|
* @internal
|
|
51
38
|
*/
|
|
52
|
-
_ref = (_startPeerSessionDecs = [_imports.trace, (0, _validateParams.default)(_schema.fcrPeerSessionParamsSchema)], _stopPeerSessionDecs = [_imports.trace, (0, _validateParams.default)(_schema.stringSchema)], _acceptPeerSessionDecs = [_imports.trace, (0, _validateParams.default)(_schema.fcrSessionBaseSchema, _schema.stringKeyUnknownValueSchema.optional())], _rejectPeerSessionDecs = [_imports.trace, (0, _validateParams.default)(_schema.fcrSessionBaseSchema, _schema.stringKeyUnknownValueSchema.optional())], "logger");
|
|
53
39
|
class FcrPeerSessionControlImpl {
|
|
40
|
+
static #_ = (() => [_initProto] = _applyDecs(this, [[_startPeerSessionDecs, 2, "startPeerSession"], [_stopPeerSessionDecs, 2, "stopPeerSession"], [_acceptPeerSessionDecs, 2, "acceptPeerSession"], [_rejectPeerSessionDecs, 2, "rejectPeerSession"]], []).e)();
|
|
41
|
+
//@internal
|
|
42
|
+
[(_startPeerSessionDecs = [_imports.trace, (0, _validateParams.default)(_schema.fcrPeerSessionParamsSchema)], _stopPeerSessionDecs = [_imports.trace, (0, _validateParams.default)(_schema.stringSchema)], _acceptPeerSessionDecs = [_imports.trace, (0, _validateParams.default)(_schema.fcrSessionBaseSchema, _schema.stringKeyUnknownValueSchema.optional())], _rejectPeerSessionDecs = [_imports.trace, (0, _validateParams.default)(_schema.fcrSessionBaseSchema, _schema.stringKeyUnknownValueSchema.optional())], "logger")] = (() => (_initProto(this), (0, _logger.createLogger)({
|
|
43
|
+
prefix: 'FcrPeerSessionControlImpl'
|
|
44
|
+
})))();
|
|
45
|
+
//@internal
|
|
46
|
+
_observable = (() => new _imports.AgoraObservable())();
|
|
47
|
+
//@internal
|
|
48
|
+
_taskInterval = (() => _imports.Duration.second(1))();
|
|
49
|
+
//@internal
|
|
50
|
+
|
|
51
|
+
//@internal
|
|
52
|
+
_scheduleMap = (() => new Map())();
|
|
53
|
+
//@internal
|
|
54
|
+
_receivedMap = (() => new Map())();
|
|
54
55
|
constructor(_rteEngine, _api, _userId) {
|
|
55
|
-
//@internal
|
|
56
|
-
(0, _defineProperty2.default)(this, _ref, (_initProto(this), (0, _logger.createLogger)({
|
|
57
|
-
prefix: 'FcrPeerSessionControlImpl'
|
|
58
|
-
})));
|
|
59
|
-
//@internal
|
|
60
|
-
(0, _defineProperty2.default)(this, "_observable", new _imports.AgoraObservable());
|
|
61
|
-
//@internal
|
|
62
|
-
(0, _defineProperty2.default)(this, "_taskInterval", _imports.Duration.second(1));
|
|
63
|
-
//@internal
|
|
64
|
-
(0, _defineProperty2.default)(this, "_scheduleMap", new Map());
|
|
65
|
-
//@internal
|
|
66
|
-
(0, _defineProperty2.default)(this, "_receivedMap", new Map());
|
|
67
56
|
this._rteEngine = _rteEngine;
|
|
68
57
|
this._api = _api;
|
|
69
58
|
this._userId = _userId;
|
|
@@ -77,7 +66,7 @@ class FcrPeerSessionControlImpl {
|
|
|
77
66
|
async startPeerSession(params) {
|
|
78
67
|
try {
|
|
79
68
|
const session = {
|
|
80
|
-
sessionId: (0, _imports.md5)(
|
|
69
|
+
sessionId: (0, _imports.md5)(`${Date.now()}`),
|
|
81
70
|
sessionKey: params.sessionKey,
|
|
82
71
|
payload: params.payload,
|
|
83
72
|
duration: params.duration,
|
|
@@ -96,11 +85,12 @@ class FcrPeerSessionControlImpl {
|
|
|
96
85
|
targetId: params.receiverId
|
|
97
86
|
});
|
|
98
87
|
const nextTs = Date.now() + interval;
|
|
99
|
-
this._scheduleMap.set(session.sessionId,
|
|
88
|
+
this._scheduleMap.set(session.sessionId, {
|
|
89
|
+
...params,
|
|
100
90
|
nextTs,
|
|
101
91
|
startTs: Date.now()
|
|
102
|
-
})
|
|
103
|
-
this.logger.info(
|
|
92
|
+
});
|
|
93
|
+
this.logger.info(`[PeerSession] put into session schedule: ${session.sessionId}, next ts: ${nextTs}, remain: ${nextTs - Date.now()}ms`);
|
|
104
94
|
return session.sessionId;
|
|
105
95
|
} catch (e) {
|
|
106
96
|
throw (0, _error.generateFcrCoreServerError)(_error.FcrErrorCode.LOCAL_HTTP_REQUEST_FAILED, 'start peer session failed', e);
|
|
@@ -169,13 +159,13 @@ class FcrPeerSessionControlImpl {
|
|
|
169
159
|
interval: 0
|
|
170
160
|
};
|
|
171
161
|
if (this._isSessionExpired(session)) {
|
|
172
|
-
this.logger.info(
|
|
162
|
+
this.logger.info(`[PeerSession] peer session expired, removed: ${session.sessionId}`);
|
|
173
163
|
this._scheduleMap.delete(session.sessionId);
|
|
174
164
|
continue;
|
|
175
165
|
}
|
|
176
166
|
// check timeout
|
|
177
167
|
if (params.nextTs < Date.now()) {
|
|
178
|
-
this.logger.info(
|
|
168
|
+
this.logger.info(`[PeerSession] ping session: ${session.sessionId}`);
|
|
179
169
|
try {
|
|
180
170
|
const {
|
|
181
171
|
data: {
|
|
@@ -191,13 +181,14 @@ class FcrPeerSessionControlImpl {
|
|
|
191
181
|
});
|
|
192
182
|
const nextTs = Date.now() + interval;
|
|
193
183
|
if (this._scheduleMap.has(session.sessionId)) {
|
|
194
|
-
this._scheduleMap.set(session.sessionId,
|
|
184
|
+
this._scheduleMap.set(session.sessionId, {
|
|
185
|
+
...params,
|
|
195
186
|
nextTs
|
|
196
|
-
})
|
|
197
|
-
this.logger.info(
|
|
187
|
+
});
|
|
188
|
+
this.logger.info(`[PeerSession] refresh session schedule: ${session.sessionId}, next ts: ${nextTs}`);
|
|
198
189
|
}
|
|
199
190
|
} catch (e) {
|
|
200
|
-
this.logger.error(
|
|
191
|
+
this.logger.error(`[PeerSession] ping session failed: ${e}`);
|
|
201
192
|
}
|
|
202
193
|
}
|
|
203
194
|
}
|
|
@@ -206,7 +197,7 @@ class FcrPeerSessionControlImpl {
|
|
|
206
197
|
const session = this._receivedMap.get(key);
|
|
207
198
|
if (this._isSessionExpired(session)) {
|
|
208
199
|
this._receivedMap.delete(key);
|
|
209
|
-
this.logger.info(
|
|
200
|
+
this.logger.info(`[PeerSession] delete session callback: ${key}`);
|
|
210
201
|
}
|
|
211
202
|
}
|
|
212
203
|
}
|
|
@@ -237,7 +228,7 @@ class FcrPeerSessionControlImpl {
|
|
|
237
228
|
}
|
|
238
229
|
if (!this._isSessionExpired(session)) {
|
|
239
230
|
if (!this._receivedMap.has(session.sessionId)) {
|
|
240
|
-
this.logger.info(
|
|
231
|
+
this.logger.info(`[PeerSession] received peer session request ${JSON.stringify(session)}`);
|
|
241
232
|
this._observable.notifyObservers('onPeerSessionReceived', session);
|
|
242
233
|
}
|
|
243
234
|
this._receivedMap.set(session.sessionId, session);
|
|
@@ -245,7 +236,6 @@ class FcrPeerSessionControlImpl {
|
|
|
245
236
|
} else if (cmd === '1002') {
|
|
246
237
|
if (data.action === 1) {
|
|
247
238
|
if (this._scheduleMap.has(data.sessionUuid)) {
|
|
248
|
-
var _session$payload, _ref2, _data$payload;
|
|
249
239
|
const session = this._scheduleMap.get(data.sessionUuid);
|
|
250
240
|
const sessionResponse = {
|
|
251
241
|
sessionId: data.sessionUuid,
|
|
@@ -253,16 +243,15 @@ class FcrPeerSessionControlImpl {
|
|
|
253
243
|
responderId: senderId,
|
|
254
244
|
// FIXME: session may be lost when the client refreshes
|
|
255
245
|
// get payload from original session
|
|
256
|
-
payload:
|
|
257
|
-
cause:
|
|
246
|
+
payload: session.payload ?? {},
|
|
247
|
+
cause: data.payload?.cause ?? {}
|
|
258
248
|
};
|
|
259
|
-
this.logger.info(
|
|
249
|
+
this.logger.info(`[PeerSession] received peer session accepted ${JSON.stringify(sessionResponse)}`);
|
|
260
250
|
this._scheduleMap.delete(data.sessionUuid);
|
|
261
251
|
this._observable.notifyObservers('onPeerSessionAccepted', sessionResponse);
|
|
262
252
|
}
|
|
263
253
|
} else if (data.action === 2) {
|
|
264
254
|
if (this._scheduleMap.has(data.sessionUuid)) {
|
|
265
|
-
var _session$payload2, _ref3, _data$payload2;
|
|
266
255
|
const session = this._scheduleMap.get(data.sessionUuid);
|
|
267
256
|
const sessionResponse = {
|
|
268
257
|
sessionId: data.sessionUuid,
|
|
@@ -270,10 +259,10 @@ class FcrPeerSessionControlImpl {
|
|
|
270
259
|
responderId: senderId,
|
|
271
260
|
// FIXME: session may be lost when the client refreshes
|
|
272
261
|
// get payload from original session
|
|
273
|
-
payload:
|
|
274
|
-
cause:
|
|
262
|
+
payload: session.payload ?? {},
|
|
263
|
+
cause: data.payload?.cause ?? {}
|
|
275
264
|
};
|
|
276
|
-
this.logger.info(
|
|
265
|
+
this.logger.info(`[PeerSession] received peer session rejected ${JSON.stringify(sessionResponse)}`);
|
|
277
266
|
if (this._scheduleMap.has(data.sessionUuid)) {
|
|
278
267
|
this._scheduleMap.delete(data.sessionUuid);
|
|
279
268
|
this._observable.notifyObservers('onPeerSessionRejected', sessionResponse);
|
|
@@ -291,6 +280,4 @@ class FcrPeerSessionControlImpl {
|
|
|
291
280
|
this.addObserver((0, _logger.generateLogObserver)(this.logger, ['onPeerSessionAccepted', 'onPeerSessionReceived', 'onPeerSessionRejected']));
|
|
292
281
|
}
|
|
293
282
|
}
|
|
294
|
-
exports.FcrPeerSessionControlImpl = FcrPeerSessionControlImpl;
|
|
295
|
-
_FcrPeerSessionControlImpl = FcrPeerSessionControlImpl;
|
|
296
|
-
[_initProto] = _applyDecs(_FcrPeerSessionControlImpl, [[_startPeerSessionDecs, 2, "startPeerSession"], [_stopPeerSessionDecs, 2, "stopPeerSession"], [_acceptPeerSessionDecs, 2, "acceptPeerSession"], [_rejectPeerSessionDecs, 2, "rejectPeerSession"]], []).e;
|
|
283
|
+
exports.FcrPeerSessionControlImpl = FcrPeerSessionControlImpl;
|