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