fcr-core 3.7.8 → 3.7.9-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-connection/index.js +26 -41
- package/lib/engine/index.js +74 -67
- package/lib/imports.js +0 -1
- package/lib/media-control/desktop.js +13 -18
- package/lib/media-control/mobile.js +13 -18
- package/lib/monitor-control/index.js +5 -10
- package/lib/peer-session/index.js +39 -48
- package/lib/plugins/chatroom.js +202 -218
- package/lib/room-control/ability-control/index.js +9 -14
- package/lib/room-control/group-control/index.js +16 -21
- package/lib/room-control/helpers/validation-helper.js +1 -1
- package/lib/room-control/index.js +36 -53
- package/lib/room-control/interpreter-control/index.js +34 -47
- 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 +17 -25
- package/lib/room-control/privilege-control/helper.js +5 -8
- package/lib/room-control/privilege-control/index.js +19 -26
- package/lib/room-control/room-connector-control/index.js +19 -28
- package/lib/room-control/room-control-factory.js +1 -2
- package/lib/room-control/room-session/index.js +39 -48
- package/lib/room-control/shared-cache.js +29 -36
- package/lib/room-control/sharing-control/index.js +32 -40
- package/lib/room-control/stream-control/index.js +173 -181
- package/lib/room-control/user-control/index.js +136 -143
- package/lib/room-control/waitingroom-control/index.js +9 -14
- package/lib/room-control/whiteboard-control-v2/annotation-control/control.js +24 -32
- package/lib/room-control/whiteboard-control-v2/annotation-control/index.js +16 -27
- package/lib/room-control/whiteboard-control-v2/annotation-control/privilege-control.js +53 -63
- package/lib/room-control/whiteboard-control-v2/index.js +28 -40
- package/lib/room-control/whiteboard-control-v2/main-window.js +23 -28
- package/lib/room-control/whiteboard-control-v2/utils.js +6 -7
- package/lib/room-control/whiteboard-control-v2/whiteboard-control/control.js +27 -38
- package/lib/room-control/whiteboard-control-v2/whiteboard-control/index.js +3 -5
- package/lib/room-control/whiteboard-control-v2/whiteboard-control/privilege-control.js +42 -54
- package/lib/room-router/index.js +42 -52
- package/lib/service/api.js +207 -231
- package/lib/utilities/collection.js +2 -3
- package/lib/utilities/error-helpers.js +27 -34
- package/lib/utilities/error.js +8 -9
- package/lib/utilities/join-helper.js +25 -32
- package/lib/utilities/logger.js +3 -6
- package/lib/utilities/parameters.js +4 -8
- package/lib/utilities/retry-helpers.js +0 -1
- package/lib/utilities/shared-storage.js +0 -1
- package/lib/utilities/storage.js +0 -1
- package/lib/utilities/stream.js +11 -16
- package/lib/utilities/user.js +3 -4
- package/lib/utilities/validate-params.js +1 -2
- package/package.json +4 -4
|
@@ -1,19 +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
4
|
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");
|
|
9
5
|
require("core-js/modules/esnext.symbol.metadata.js");
|
|
10
6
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
11
7
|
Object.defineProperty(exports, "__esModule", {
|
|
12
8
|
value: true
|
|
13
9
|
});
|
|
14
10
|
exports.FcrPeerSessionControlImpl = void 0;
|
|
15
|
-
require("core-js/modules/es.error.cause.js");
|
|
16
|
-
require("core-js/modules/es.json.stringify.js");
|
|
17
11
|
require("core-js/modules/esnext.map.delete-all.js");
|
|
18
12
|
require("core-js/modules/esnext.map.emplace.js");
|
|
19
13
|
require("core-js/modules/esnext.map.every.js");
|
|
@@ -28,17 +22,12 @@ require("core-js/modules/esnext.map.merge.js");
|
|
|
28
22
|
require("core-js/modules/esnext.map.reduce.js");
|
|
29
23
|
require("core-js/modules/esnext.map.some.js");
|
|
30
24
|
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"));
|
|
33
25
|
var _imports = require("../imports");
|
|
34
26
|
var _error = require("../utilities/error");
|
|
35
27
|
var _logger = require("../utilities/logger");
|
|
36
28
|
var _schema = require("../schema");
|
|
37
29
|
var _validateParams = _interopRequireDefault(require("../utilities/validate-params"));
|
|
38
|
-
|
|
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; }
|
|
30
|
+
let _initProto, _startPeerSessionDecs, _stopPeerSessionDecs, _acceptPeerSessionDecs, _rejectPeerSessionDecs;
|
|
42
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)]; } }; }
|
|
43
32
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
44
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); }
|
|
@@ -47,21 +36,25 @@ function _checkInRHS(e) { if (Object(e) !== e) throw TypeError("right-hand side
|
|
|
47
36
|
/**
|
|
48
37
|
* @internal
|
|
49
38
|
*/
|
|
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");
|
|
51
39
|
class FcrPeerSessionControlImpl {
|
|
40
|
+
static {
|
|
41
|
+
[_initProto] = _applyDecs(this, [[_startPeerSessionDecs, 2, "startPeerSession"], [_stopPeerSessionDecs, 2, "stopPeerSession"], [_acceptPeerSessionDecs, 2, "acceptPeerSession"], [_rejectPeerSessionDecs, 2, "rejectPeerSession"]], []).e;
|
|
42
|
+
}
|
|
43
|
+
//@internal
|
|
44
|
+
[(_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)({
|
|
45
|
+
prefix: 'FcrPeerSessionControlImpl'
|
|
46
|
+
}));
|
|
47
|
+
//@internal
|
|
48
|
+
_observable = new _imports.AgoraObservable();
|
|
49
|
+
//@internal
|
|
50
|
+
_taskInterval = _imports.Duration.second(1);
|
|
51
|
+
//@internal
|
|
52
|
+
|
|
53
|
+
//@internal
|
|
54
|
+
_scheduleMap = new Map();
|
|
55
|
+
//@internal
|
|
56
|
+
_receivedMap = new Map();
|
|
52
57
|
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());
|
|
65
58
|
this._rteEngine = _rteEngine;
|
|
66
59
|
this._api = _api;
|
|
67
60
|
this._userId = _userId;
|
|
@@ -75,7 +68,7 @@ class FcrPeerSessionControlImpl {
|
|
|
75
68
|
async startPeerSession(params) {
|
|
76
69
|
try {
|
|
77
70
|
const session = {
|
|
78
|
-
sessionId: (0, _imports.md5)(
|
|
71
|
+
sessionId: (0, _imports.md5)(`${Date.now()}`),
|
|
79
72
|
sessionKey: params.sessionKey,
|
|
80
73
|
payload: params.payload,
|
|
81
74
|
duration: params.duration,
|
|
@@ -94,11 +87,12 @@ class FcrPeerSessionControlImpl {
|
|
|
94
87
|
targetId: params.receiverId
|
|
95
88
|
});
|
|
96
89
|
const nextTs = Date.now() + interval;
|
|
97
|
-
this._scheduleMap.set(session.sessionId,
|
|
90
|
+
this._scheduleMap.set(session.sessionId, {
|
|
91
|
+
...params,
|
|
98
92
|
nextTs,
|
|
99
93
|
startTs: Date.now()
|
|
100
|
-
})
|
|
101
|
-
this.logger.info(
|
|
94
|
+
});
|
|
95
|
+
this.logger.info(`[PeerSession] put into session schedule: ${session.sessionId}, next ts: ${nextTs}, remain: ${nextTs - Date.now()}ms`);
|
|
102
96
|
return session.sessionId;
|
|
103
97
|
} catch (e) {
|
|
104
98
|
throw (0, _error.generateFcrCoreServerError)(_error.FcrErrorCode.LOCAL_HTTP_REQUEST_FAILED, 'start peer session failed', e);
|
|
@@ -167,13 +161,13 @@ class FcrPeerSessionControlImpl {
|
|
|
167
161
|
interval: 0
|
|
168
162
|
};
|
|
169
163
|
if (this._isSessionExpired(session)) {
|
|
170
|
-
this.logger.info(
|
|
164
|
+
this.logger.info(`[PeerSession] peer session expired, removed: ${session.sessionId}`);
|
|
171
165
|
this._scheduleMap.delete(session.sessionId);
|
|
172
166
|
continue;
|
|
173
167
|
}
|
|
174
168
|
// check timeout
|
|
175
169
|
if (params.nextTs < Date.now()) {
|
|
176
|
-
this.logger.info(
|
|
170
|
+
this.logger.info(`[PeerSession] ping session: ${session.sessionId}`);
|
|
177
171
|
try {
|
|
178
172
|
const {
|
|
179
173
|
data: {
|
|
@@ -189,13 +183,14 @@ class FcrPeerSessionControlImpl {
|
|
|
189
183
|
});
|
|
190
184
|
const nextTs = Date.now() + interval;
|
|
191
185
|
if (this._scheduleMap.has(session.sessionId)) {
|
|
192
|
-
this._scheduleMap.set(session.sessionId,
|
|
186
|
+
this._scheduleMap.set(session.sessionId, {
|
|
187
|
+
...params,
|
|
193
188
|
nextTs
|
|
194
|
-
})
|
|
195
|
-
this.logger.info(
|
|
189
|
+
});
|
|
190
|
+
this.logger.info(`[PeerSession] refresh session schedule: ${session.sessionId}, next ts: ${nextTs}`);
|
|
196
191
|
}
|
|
197
192
|
} catch (e) {
|
|
198
|
-
this.logger.error(
|
|
193
|
+
this.logger.error(`[PeerSession] ping session failed: ${e}`);
|
|
199
194
|
}
|
|
200
195
|
}
|
|
201
196
|
}
|
|
@@ -204,7 +199,7 @@ class FcrPeerSessionControlImpl {
|
|
|
204
199
|
const session = this._receivedMap.get(key);
|
|
205
200
|
if (this._isSessionExpired(session)) {
|
|
206
201
|
this._receivedMap.delete(key);
|
|
207
|
-
this.logger.info(
|
|
202
|
+
this.logger.info(`[PeerSession] delete session callback: ${key}`);
|
|
208
203
|
}
|
|
209
204
|
}
|
|
210
205
|
}
|
|
@@ -235,7 +230,7 @@ class FcrPeerSessionControlImpl {
|
|
|
235
230
|
}
|
|
236
231
|
if (!this._isSessionExpired(session)) {
|
|
237
232
|
if (!this._receivedMap.has(session.sessionId)) {
|
|
238
|
-
this.logger.info(
|
|
233
|
+
this.logger.info(`[PeerSession] received peer session request ${JSON.stringify(session)}`);
|
|
239
234
|
this._observable.notifyObservers('onPeerSessionReceived', session);
|
|
240
235
|
}
|
|
241
236
|
this._receivedMap.set(session.sessionId, session);
|
|
@@ -243,7 +238,6 @@ class FcrPeerSessionControlImpl {
|
|
|
243
238
|
} else if (cmd === '1002') {
|
|
244
239
|
if (data.action === 1) {
|
|
245
240
|
if (this._scheduleMap.has(data.sessionUuid)) {
|
|
246
|
-
var _session$payload, _ref2, _data$payload;
|
|
247
241
|
const session = this._scheduleMap.get(data.sessionUuid);
|
|
248
242
|
const sessionResponse = {
|
|
249
243
|
sessionId: data.sessionUuid,
|
|
@@ -251,16 +245,15 @@ class FcrPeerSessionControlImpl {
|
|
|
251
245
|
responderId: senderId,
|
|
252
246
|
// FIXME: session may be lost when the client refreshes
|
|
253
247
|
// get payload from original session
|
|
254
|
-
payload:
|
|
255
|
-
cause:
|
|
248
|
+
payload: session.payload ?? {},
|
|
249
|
+
cause: data.payload?.cause ?? {}
|
|
256
250
|
};
|
|
257
|
-
this.logger.info(
|
|
251
|
+
this.logger.info(`[PeerSession] received peer session accepted ${JSON.stringify(sessionResponse)}`);
|
|
258
252
|
this._scheduleMap.delete(data.sessionUuid);
|
|
259
253
|
this._observable.notifyObservers('onPeerSessionAccepted', sessionResponse);
|
|
260
254
|
}
|
|
261
255
|
} else if (data.action === 2) {
|
|
262
256
|
if (this._scheduleMap.has(data.sessionUuid)) {
|
|
263
|
-
var _session$payload2, _ref3, _data$payload2;
|
|
264
257
|
const session = this._scheduleMap.get(data.sessionUuid);
|
|
265
258
|
const sessionResponse = {
|
|
266
259
|
sessionId: data.sessionUuid,
|
|
@@ -268,10 +261,10 @@ class FcrPeerSessionControlImpl {
|
|
|
268
261
|
responderId: senderId,
|
|
269
262
|
// FIXME: session may be lost when the client refreshes
|
|
270
263
|
// get payload from original session
|
|
271
|
-
payload:
|
|
272
|
-
cause:
|
|
264
|
+
payload: session.payload ?? {},
|
|
265
|
+
cause: data.payload?.cause ?? {}
|
|
273
266
|
};
|
|
274
|
-
this.logger.info(
|
|
267
|
+
this.logger.info(`[PeerSession] received peer session rejected ${JSON.stringify(sessionResponse)}`);
|
|
275
268
|
if (this._scheduleMap.has(data.sessionUuid)) {
|
|
276
269
|
this._scheduleMap.delete(data.sessionUuid);
|
|
277
270
|
this._observable.notifyObservers('onPeerSessionRejected', sessionResponse);
|
|
@@ -289,6 +282,4 @@ class FcrPeerSessionControlImpl {
|
|
|
289
282
|
this.addObserver((0, _logger.generateLogObserver)(this.logger, ['onPeerSessionAccepted', 'onPeerSessionReceived', 'onPeerSessionRejected']));
|
|
290
283
|
}
|
|
291
284
|
}
|
|
292
|
-
exports.FcrPeerSessionControlImpl = FcrPeerSessionControlImpl;
|
|
293
|
-
_FcrPeerSessionControlImpl = FcrPeerSessionControlImpl;
|
|
294
|
-
[_initProto] = _applyDecs(_FcrPeerSessionControlImpl, [[_startPeerSessionDecs, 2, "startPeerSession"], [_stopPeerSessionDecs, 2, "stopPeerSession"], [_acceptPeerSessionDecs, 2, "acceptPeerSession"], [_rejectPeerSessionDecs, 2, "rejectPeerSession"]], []).e;
|
|
285
|
+
exports.FcrPeerSessionControlImpl = FcrPeerSessionControlImpl;
|