fcr-core 3.10.5 → 3.10.6
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/engine/index.js +108 -102
- package/lib/imports.js +0 -1
- package/lib/index.d.ts +1 -1
- package/lib/media-control/desktop.js +13 -22
- package/lib/media-control/mobile.js +13 -22
- package/lib/monitor-control/index.js +7 -17
- package/lib/peer-session/index.js +121 -120
- package/lib/plugins/chat/chatroom.js +96 -119
- package/lib/plugins/chat/connector.js +48 -69
- package/lib/remote-control/index.js +216 -194
- package/lib/room-control/ability-control/index.js +10 -20
- package/lib/room-control/application-control/index.js +75 -82
- package/lib/room-control/group-control/index.js +30 -31
- package/lib/room-control/helpers/board-init-info-helper.js +10 -16
- package/lib/room-control/helpers/validation-helper.js +1 -1
- package/lib/room-control/index.js +51 -70
- package/lib/room-control/infinity-room-control/index.js +19 -27
- package/lib/room-control/interpreter-control/index.js +65 -77
- 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 +25 -37
- package/lib/room-control/privilege-control/helper.js +13 -28
- package/lib/room-control/privilege-control/index.js +28 -36
- package/lib/room-control/room-connector-control/index.js +47 -52
- package/lib/room-control/room-control-factory.js +12 -10
- package/lib/room-control/room-session/index.js +74 -77
- package/lib/room-control/shared-cache.js +56 -63
- package/lib/room-control/sharing-control/index.js +57 -65
- package/lib/room-control/stream-control/index.js +238 -203
- package/lib/room-control/stream-control/type.d.ts +11 -1
- package/lib/room-control/stt-control/de-compress-gzip.js +0 -10
- package/lib/room-control/stt-control/index.js +86 -93
- package/lib/room-control/user-control/index.js +155 -162
- package/lib/room-control/waitingroom-control/index.js +9 -18
- package/lib/room-control/whiteboard-control/utils.js +2 -4
- package/lib/room-control/whiteboard-control-v1/board-subwindow.js +1 -2
- package/lib/room-control/whiteboard-control-v1/board-window.js +103 -120
- package/lib/room-control/whiteboard-control-v1/factory.js +4 -7
- package/lib/room-control/whiteboard-control-v1/index.js +67 -80
- package/lib/room-control/whiteboard-control-v1/mount-manager.js +2 -4
- package/lib/room-control/whiteboard-control-v1/utils.js +14 -17
- package/lib/room-control/whiteboard-control-v2/annotation-control/control.js +10 -14
- package/lib/room-control/whiteboard-control-v2/annotation-control/factory.js +8 -17
- package/lib/room-control/whiteboard-control-v2/base/index.js +53 -61
- package/lib/room-control/whiteboard-control-v2/base/main-window.js +30 -39
- package/lib/room-control/whiteboard-control-v2/utils.js +10 -10
- package/lib/room-control/whiteboard-control-v2/whiteboard-control/control.js +33 -45
- package/lib/room-control/whiteboard-control-v2/whiteboard-control/factory.js +11 -27
- package/lib/room-control/widget-control/index.js +33 -43
- package/lib/room-router/index.js +58 -66
- package/lib/service/api.js +548 -446
- package/lib/struct.js +2 -5
- package/lib/type.d.ts +1 -1
- package/lib/utilities/abortable-retry.js +0 -3
- package/lib/utilities/collection.js +11 -15
- package/lib/utilities/error-helpers.js +27 -34
- package/lib/utilities/error.js +3 -4
- package/lib/utilities/join-helper.js +31 -37
- package/lib/utilities/logger.js +5 -8
- package/lib/utilities/parameters.js +10 -21
- package/lib/utilities/retry-helpers.js +0 -1
- package/lib/utilities/stream.js +11 -16
- package/lib/utilities/user.js +3 -4
- package/lib/utilities/validate-params.js +1 -1
- package/lib/utilities/video-encoder-config.js +5 -10
- package/lib-es/engine/index.js +108 -102
- package/lib-es/media-control/desktop.js +13 -22
- package/lib-es/media-control/mobile.js +13 -22
- package/lib-es/monitor-control/index.js +7 -16
- package/lib-es/peer-session/index.js +121 -120
- package/lib-es/plugins/chat/chatroom.js +95 -118
- package/lib-es/plugins/chat/connector.js +47 -67
- package/lib-es/remote-control/index.js +216 -194
- package/lib-es/room-control/ability-control/index.js +10 -19
- package/lib-es/room-control/application-control/index.js +75 -81
- package/lib-es/room-control/group-control/index.js +30 -31
- package/lib-es/room-control/helpers/board-init-info-helper.js +10 -15
- package/lib-es/room-control/helpers/validation-helper.js +1 -1
- package/lib-es/room-control/index.js +51 -69
- package/lib-es/room-control/infinity-room-control/index.js +19 -26
- package/lib-es/room-control/interpreter-control/index.js +65 -77
- package/lib-es/room-control/interpreter-control/room.js +4 -5
- package/lib-es/room-control/join-before-host-waitingroom-control/index.js +4 -5
- package/lib-es/room-control/mainroom-control/index.js +25 -37
- package/lib-es/room-control/privilege-control/helper.js +13 -27
- package/lib-es/room-control/privilege-control/index.js +28 -36
- package/lib-es/room-control/room-connector-control/index.js +47 -52
- package/lib-es/room-control/room-control-factory.js +12 -10
- package/lib-es/room-control/room-session/index.js +74 -77
- package/lib-es/room-control/shared-cache.js +56 -62
- package/lib-es/room-control/sharing-control/index.js +57 -64
- package/lib-es/room-control/stream-control/index.js +240 -205
- package/lib-es/room-control/stt-control/de-compress-gzip.js +0 -10
- package/lib-es/room-control/stt-control/index.js +86 -93
- package/lib-es/room-control/user-control/index.js +155 -162
- package/lib-es/room-control/waitingroom-control/index.js +9 -18
- package/lib-es/room-control/whiteboard-control/utils.js +2 -4
- package/lib-es/room-control/whiteboard-control-v1/board-subwindow.js +1 -2
- package/lib-es/room-control/whiteboard-control-v1/board-window.js +103 -120
- package/lib-es/room-control/whiteboard-control-v1/factory.js +4 -6
- package/lib-es/room-control/whiteboard-control-v1/index.js +67 -80
- package/lib-es/room-control/whiteboard-control-v1/mount-manager.js +2 -3
- package/lib-es/room-control/whiteboard-control-v1/utils.js +14 -17
- package/lib-es/room-control/whiteboard-control-v2/annotation-control/control.js +10 -13
- package/lib-es/room-control/whiteboard-control-v2/annotation-control/factory.js +8 -16
- package/lib-es/room-control/whiteboard-control-v2/base/index.js +53 -60
- package/lib-es/room-control/whiteboard-control-v2/base/main-window.js +30 -39
- package/lib-es/room-control/whiteboard-control-v2/utils.js +10 -10
- package/lib-es/room-control/whiteboard-control-v2/whiteboard-control/control.js +33 -45
- package/lib-es/room-control/whiteboard-control-v2/whiteboard-control/factory.js +11 -26
- package/lib-es/room-control/widget-control/index.js +33 -42
- package/lib-es/room-router/index.js +58 -66
- package/lib-es/service/api.js +548 -445
- package/lib-es/struct.js +2 -4
- package/lib-es/utilities/abortable-retry.js +0 -3
- package/lib-es/utilities/collection.js +11 -14
- package/lib-es/utilities/error-helpers.js +26 -33
- package/lib-es/utilities/error.js +3 -4
- package/lib-es/utilities/join-helper.js +29 -36
- package/lib-es/utilities/logger.js +5 -7
- package/lib-es/utilities/parameters.js +10 -21
- package/lib-es/utilities/retry-helpers.js +0 -1
- package/lib-es/utilities/stream.js +11 -15
- package/lib-es/utilities/user.js +3 -4
- package/lib-es/utilities/validate-params.js +1 -1
- package/lib-es/utilities/video-encoder-config.js +5 -10
- package/package.json +4 -4
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
import "core-js/modules/es.symbol.description.js";
|
|
2
|
-
import "core-js/modules/es.error.cause.js";
|
|
3
1
|
import "core-js/modules/es.array.push.js";
|
|
4
2
|
import "core-js/modules/esnext.function.metadata.js";
|
|
5
|
-
import "core-js/modules/esnext.iterator.constructor.js";
|
|
6
|
-
import "core-js/modules/esnext.iterator.filter.js";
|
|
7
|
-
import "core-js/modules/esnext.iterator.for-each.js";
|
|
8
3
|
import "core-js/modules/esnext.map.delete-all.js";
|
|
9
4
|
import "core-js/modules/esnext.map.emplace.js";
|
|
10
5
|
import "core-js/modules/esnext.map.every.js";
|
|
@@ -20,16 +15,7 @@ import "core-js/modules/esnext.map.reduce.js";
|
|
|
20
15
|
import "core-js/modules/esnext.map.some.js";
|
|
21
16
|
import "core-js/modules/esnext.map.update.js";
|
|
22
17
|
import "core-js/modules/esnext.symbol.metadata.js";
|
|
23
|
-
|
|
24
|
-
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
25
|
-
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
26
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
27
|
-
const _excluded = ["action", "keepAlive"],
|
|
28
|
-
_excluded2 = ["action"];
|
|
29
|
-
var _FcrRemoteControlImpl;
|
|
30
|
-
let _initProto, _startRemoteControlRequestDecs, _acceptRemoteControlRequestDecs, _rejectRemoteControlRequestDecs, _terminateRemoteControlDecs, _updateRemoteControlConnectionStateDecs, _ref;
|
|
31
|
-
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; }
|
|
32
|
-
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) { _defineProperty(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; }
|
|
18
|
+
let _initProto, _startRemoteControlRequestDecs, _acceptRemoteControlRequestDecs, _rejectRemoteControlRequestDecs, _terminateRemoteControlDecs, _updateRemoteControlConnectionStateDecs;
|
|
33
19
|
import "core-js/modules/es.json.stringify.js";
|
|
34
20
|
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)]; } }; }
|
|
35
21
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
@@ -44,24 +30,28 @@ import { fcrRemoteControlConnectionStateTypeSchema, fcrRemoteControlSessionParam
|
|
|
44
30
|
import { generateFcrCoreClientError, generateFcrCoreServerError } from '../utilities/error';
|
|
45
31
|
import { bound } from '../imports';
|
|
46
32
|
export const KEEPALIVE_TIMEOUT_MULTIPLIER = 2;
|
|
47
|
-
_ref = (_startRemoteControlRequestDecs = [trace(['params']), validateParams(fcrRemoteControlSessionParamsSchema)], _acceptRemoteControlRequestDecs = [trace(['sessionId', 'cause']), validateParams(stringSchema, stringKeyUnknownValueSchema.optional())], _rejectRemoteControlRequestDecs = [trace(['sessionId', 'cause']), validateParams(stringSchema, stringKeyUnknownValueSchema.optional())], _terminateRemoteControlDecs = [trace(['sessionId', 'cause']), validateParams(stringSchema, stringKeyUnknownValueSchema.optional())], _updateRemoteControlConnectionStateDecs = [trace(['sessionId', 'state', 'cause']), validateParams(stringSchema, fcrRemoteControlConnectionStateTypeSchema, stringKeyUnknownValueSchema.optional())], "logger");
|
|
48
33
|
export class FcrRemoteControlImpl {
|
|
34
|
+
static {
|
|
35
|
+
[_initProto] = _applyDecs(this, [[_startRemoteControlRequestDecs, 2, "startRemoteControlRequest"], [_acceptRemoteControlRequestDecs, 2, "acceptRemoteControlRequest"], [_rejectRemoteControlRequestDecs, 2, "rejectRemoteControlRequest"], [_terminateRemoteControlDecs, 2, "terminateRemoteControl"], [_updateRemoteControlConnectionStateDecs, 2, "updateRemoteControlConnectionState"], [trace, 2, "getRemoteControlState"], [bound, 2, "_notifyRemoteControlState"]], []).e;
|
|
36
|
+
}
|
|
37
|
+
[(_startRemoteControlRequestDecs = [trace(['params']), validateParams(fcrRemoteControlSessionParamsSchema)], _acceptRemoteControlRequestDecs = [trace(['sessionId', 'cause']), validateParams(stringSchema, stringKeyUnknownValueSchema.optional())], _rejectRemoteControlRequestDecs = [trace(['sessionId', 'cause']), validateParams(stringSchema, stringKeyUnknownValueSchema.optional())], _terminateRemoteControlDecs = [trace(['sessionId', 'cause']), validateParams(stringSchema, stringKeyUnknownValueSchema.optional())], _updateRemoteControlConnectionStateDecs = [trace(['sessionId', 'state', 'cause']), validateParams(stringSchema, fcrRemoteControlConnectionStateTypeSchema, stringKeyUnknownValueSchema.optional())], "logger")] = (_initProto(this), createLogger({
|
|
38
|
+
prefix: 'FcrRemoteControlImpl'
|
|
39
|
+
}));
|
|
40
|
+
_remoteControlSessionKey = 'remote-control';
|
|
41
|
+
_observable = new AgoraObservable();
|
|
42
|
+
//@internal
|
|
43
|
+
_taskInterval = Duration.second(1);
|
|
44
|
+
//@internal
|
|
45
|
+
|
|
46
|
+
//@internal
|
|
47
|
+
_engineObserver = {
|
|
48
|
+
onPeerMessageReceived: this._handleRemoteControlMessage.bind(this)
|
|
49
|
+
};
|
|
50
|
+
//@internal 控制端会话信息
|
|
51
|
+
_activeRemoteControlSession = null;
|
|
52
|
+
//@internal 被控制端会话信息
|
|
53
|
+
_receivedRemoteControlSession = null;
|
|
49
54
|
constructor(_rteEngine, _api, _userId) {
|
|
50
|
-
_defineProperty(this, _ref, (_initProto(this), createLogger({
|
|
51
|
-
prefix: 'FcrRemoteControlImpl'
|
|
52
|
-
})));
|
|
53
|
-
_defineProperty(this, "_remoteControlSessionKey", 'remote-control');
|
|
54
|
-
_defineProperty(this, "_observable", new AgoraObservable());
|
|
55
|
-
//@internal
|
|
56
|
-
_defineProperty(this, "_taskInterval", Duration.second(1));
|
|
57
|
-
//@internal
|
|
58
|
-
_defineProperty(this, "_engineObserver", {
|
|
59
|
-
onPeerMessageReceived: this._handleRemoteControlMessage.bind(this)
|
|
60
|
-
});
|
|
61
|
-
//@internal 控制端会话信息
|
|
62
|
-
_defineProperty(this, "_activeRemoteControlSession", null);
|
|
63
|
-
//@internal 被控制端会话信息
|
|
64
|
-
_defineProperty(this, "_receivedRemoteControlSession", null);
|
|
65
55
|
this._rteEngine = _rteEngine;
|
|
66
56
|
this._api = _api;
|
|
67
57
|
this._userId = _userId;
|
|
@@ -69,27 +59,30 @@ export class FcrRemoteControlImpl {
|
|
|
69
59
|
this._executeTask = this._executeTask.bind(this);
|
|
70
60
|
this._rteEngine.addObserver(this._engineObserver);
|
|
71
61
|
this._task = AgoraScheduler.shared.addPollingTask(this._executeTask, this._taskInterval, true, () => ActionWhenTaskFail.CONTINUE);
|
|
72
|
-
this.logger.info(
|
|
62
|
+
this.logger.info(`remote control initialized FcrRemoteControlImpl userId: ${this._userId}`);
|
|
73
63
|
}
|
|
74
64
|
|
|
75
65
|
//@internal
|
|
76
66
|
async _handleRemoteControlMessage(message) {
|
|
77
|
-
const
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
67
|
+
const {
|
|
68
|
+
senderId,
|
|
69
|
+
payload
|
|
70
|
+
} = message;
|
|
71
|
+
const {
|
|
72
|
+
data,
|
|
73
|
+
cmd
|
|
74
|
+
} = payload;
|
|
75
|
+
const logContext = `cmd=${cmd}, sessionKey=${data.sessionKey}, sessionId=${data.sessionUuid}, ` + `action=${String(data.action)}, senderId=${senderId}, keepAlive=${!!data.keepAlive}`;
|
|
83
76
|
if (data.sessionKey !== this._remoteControlSessionKey) {
|
|
84
|
-
this.logger.info(
|
|
77
|
+
this.logger.info(`[RemoteControl] ignore peer message because sessionKey does not match remote-control: ${logContext}`);
|
|
85
78
|
return;
|
|
86
79
|
}
|
|
87
80
|
if (cmd === '1001') {
|
|
88
81
|
if (!data.keepAlive) {
|
|
89
|
-
this.logger.info(
|
|
82
|
+
this.logger.info(`[RemoteControl] ignore remote-control update without keepAlive: ${logContext}`);
|
|
90
83
|
return;
|
|
91
84
|
}
|
|
92
|
-
this.logger.info(
|
|
85
|
+
this.logger.info(`[RemoteControl] forward update session for handling: ${logContext}`);
|
|
93
86
|
return await this._handleUpdateRemoteControlSession({
|
|
94
87
|
senderId: senderId,
|
|
95
88
|
sessionKey: data.sessionKey,
|
|
@@ -102,7 +95,7 @@ export class FcrRemoteControlImpl {
|
|
|
102
95
|
timestamp: message.timestamp
|
|
103
96
|
});
|
|
104
97
|
} else if (cmd === '1002') {
|
|
105
|
-
this.logger.info(
|
|
98
|
+
this.logger.info(`[RemoteControl] forward delete session for handling: ${logContext}`);
|
|
106
99
|
return await this._handleDeleteRemoteControlSession({
|
|
107
100
|
senderId: senderId,
|
|
108
101
|
sessionKey: data.sessionKey,
|
|
@@ -114,13 +107,15 @@ export class FcrRemoteControlImpl {
|
|
|
114
107
|
timestamp: message.timestamp
|
|
115
108
|
});
|
|
116
109
|
} else {
|
|
117
|
-
this.logger.info(
|
|
110
|
+
this.logger.info(`[RemoteControl] ignore unsupported cmd: ${logContext}`);
|
|
118
111
|
}
|
|
119
112
|
}
|
|
120
113
|
async _handleUpdateRemoteControlSession(data) {
|
|
121
|
-
const
|
|
122
|
-
|
|
123
|
-
|
|
114
|
+
const {
|
|
115
|
+
action,
|
|
116
|
+
keepAlive,
|
|
117
|
+
...session
|
|
118
|
+
} = data;
|
|
124
119
|
if (this._isSessionExpired({
|
|
125
120
|
timestamp: session.timestamp,
|
|
126
121
|
duration: session.duration
|
|
@@ -128,10 +123,11 @@ export class FcrRemoteControlImpl {
|
|
|
128
123
|
this.terminateRemoteControl(session.sessionId);
|
|
129
124
|
return;
|
|
130
125
|
}
|
|
131
|
-
const
|
|
132
|
-
state
|
|
133
|
-
cause
|
|
134
|
-
|
|
126
|
+
const {
|
|
127
|
+
state,
|
|
128
|
+
cause
|
|
129
|
+
} = data.payload;
|
|
130
|
+
const _cause = cause ?? {};
|
|
135
131
|
switch (action) {
|
|
136
132
|
case 0:
|
|
137
133
|
{
|
|
@@ -151,7 +147,7 @@ export class FcrRemoteControlImpl {
|
|
|
151
147
|
},
|
|
152
148
|
state
|
|
153
149
|
};
|
|
154
|
-
this.logger.info(
|
|
150
|
+
this.logger.info(`on received remote control session request ${JSON.stringify(session)}`);
|
|
155
151
|
this._notifyRemoteControlState(state, {
|
|
156
152
|
sessionId: session.sessionId,
|
|
157
153
|
fromUserId: session.senderId,
|
|
@@ -175,28 +171,30 @@ export class FcrRemoteControlImpl {
|
|
|
175
171
|
});
|
|
176
172
|
}
|
|
177
173
|
// 相同的状态则是维系心跳
|
|
178
|
-
this._receivedRemoteControlSession.session =
|
|
174
|
+
this._receivedRemoteControlSession.session = {
|
|
175
|
+
...this._receivedRemoteControlSession.session,
|
|
179
176
|
nextTs: Date.now() + session.interval,
|
|
180
177
|
action
|
|
181
|
-
}
|
|
178
|
+
};
|
|
182
179
|
break;
|
|
183
180
|
}
|
|
184
181
|
case 1:
|
|
185
182
|
{
|
|
186
183
|
if (!this._activeRemoteControlSession && !this._receivedRemoteControlSession) {
|
|
187
|
-
this.logger.error(
|
|
184
|
+
this.logger.error(`on upadte remote control session state: ${state}, session: ${JSON.stringify(session)}, but local remote control session not found`);
|
|
188
185
|
return;
|
|
189
186
|
}
|
|
190
|
-
this.logger.info(
|
|
187
|
+
this.logger.info(`on upadte remote control session state: ${state}, session: ${JSON.stringify(session)}`);
|
|
191
188
|
if (this._receivedRemoteControlSession && this._receivedRemoteControlSession.sessionId === session.sessionId) {
|
|
192
189
|
let oldState = this._receivedRemoteControlSession.state;
|
|
193
190
|
this._receivedRemoteControlSession.state = state;
|
|
194
|
-
this._receivedRemoteControlSession.session =
|
|
191
|
+
this._receivedRemoteControlSession.session = {
|
|
192
|
+
...this._receivedRemoteControlSession.session,
|
|
195
193
|
cause: _cause,
|
|
196
194
|
action,
|
|
197
195
|
nextTs: Date.now() + session.interval,
|
|
198
196
|
startTs: Date.now()
|
|
199
|
-
}
|
|
197
|
+
};
|
|
200
198
|
// 如果来自心跳,相同状态下就不要上报了
|
|
201
199
|
if (oldState === state) {
|
|
202
200
|
return;
|
|
@@ -212,10 +210,11 @@ export class FcrRemoteControlImpl {
|
|
|
212
210
|
} else if (this._activeRemoteControlSession && this._activeRemoteControlSession.sessionId === session.sessionId) {
|
|
213
211
|
let oldState = this._activeRemoteControlSession.state;
|
|
214
212
|
this._activeRemoteControlSession.state = state;
|
|
215
|
-
this._activeRemoteControlSession.session =
|
|
213
|
+
this._activeRemoteControlSession.session = {
|
|
214
|
+
...this._activeRemoteControlSession.session,
|
|
216
215
|
cause: _cause,
|
|
217
216
|
action
|
|
218
|
-
}
|
|
217
|
+
};
|
|
219
218
|
// 如果来自心跳,相同状态下就不要上报了
|
|
220
219
|
if (oldState === state) {
|
|
221
220
|
return;
|
|
@@ -234,12 +233,15 @@ export class FcrRemoteControlImpl {
|
|
|
234
233
|
}
|
|
235
234
|
}
|
|
236
235
|
async _handleDeleteRemoteControlSession(data) {
|
|
237
|
-
const
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
236
|
+
const {
|
|
237
|
+
action,
|
|
238
|
+
...session
|
|
239
|
+
} = data;
|
|
240
|
+
const {
|
|
241
|
+
state,
|
|
242
|
+
cause
|
|
243
|
+
} = data.payload;
|
|
244
|
+
const _cause = cause ?? {};
|
|
243
245
|
switch (action) {
|
|
244
246
|
case 2:
|
|
245
247
|
{
|
|
@@ -253,7 +255,7 @@ export class FcrRemoteControlImpl {
|
|
|
253
255
|
cause: _cause
|
|
254
256
|
});
|
|
255
257
|
this._activeRemoteControlSession = null;
|
|
256
|
-
this.logger.info(
|
|
258
|
+
this.logger.info(`on reject remote control session state: ${state}, ${JSON.stringify(session)}`);
|
|
257
259
|
}
|
|
258
260
|
break;
|
|
259
261
|
}
|
|
@@ -273,7 +275,7 @@ export class FcrRemoteControlImpl {
|
|
|
273
275
|
});
|
|
274
276
|
this._activeRemoteControlSession = null;
|
|
275
277
|
this._receivedRemoteControlSession = null;
|
|
276
|
-
this.logger.info(
|
|
278
|
+
this.logger.info(`on delete remote control session state: ${state}, ${JSON.stringify(session)}`);
|
|
277
279
|
}
|
|
278
280
|
break;
|
|
279
281
|
}
|
|
@@ -287,7 +289,7 @@ export class FcrRemoteControlImpl {
|
|
|
287
289
|
try {
|
|
288
290
|
await this.terminateRemoteControl(sessionId);
|
|
289
291
|
} catch (e) {
|
|
290
|
-
this.logger.error(
|
|
292
|
+
this.logger.error(`remote control ${context}: ${e}`);
|
|
291
293
|
}
|
|
292
294
|
}
|
|
293
295
|
|
|
@@ -295,61 +297,67 @@ export class FcrRemoteControlImpl {
|
|
|
295
297
|
async _executeTask() {
|
|
296
298
|
// ping sessions (sender side)
|
|
297
299
|
if (this._activeRemoteControlSession) {
|
|
298
|
-
const
|
|
299
|
-
sessionId
|
|
300
|
-
session
|
|
301
|
-
state
|
|
300
|
+
const {
|
|
301
|
+
sessionId,
|
|
302
|
+
session,
|
|
303
|
+
state
|
|
304
|
+
} = this._activeRemoteControlSession;
|
|
302
305
|
if (this._isSessionExpired({
|
|
303
306
|
duration: session.duration,
|
|
304
307
|
timestamp: session.timestamp
|
|
305
308
|
})) {
|
|
306
|
-
this.logger.info(
|
|
309
|
+
this.logger.info(`remote control session expired, removed: ${sessionId}`);
|
|
307
310
|
await this._terminateRemoteControlBestEffort(sessionId, 'terminate remote control session on active side expiry');
|
|
308
311
|
return;
|
|
309
312
|
}
|
|
310
313
|
if (session.nextTs < Date.now()) {
|
|
311
|
-
this.logger.info(
|
|
314
|
+
this.logger.info(`ping remote control session: ${sessionId}`);
|
|
312
315
|
try {
|
|
313
|
-
const
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
}
|
|
326
|
-
|
|
316
|
+
const {
|
|
317
|
+
data: {
|
|
318
|
+
interval
|
|
319
|
+
}
|
|
320
|
+
} = await this._api.updatePeerSession({
|
|
321
|
+
userId: this._userId,
|
|
322
|
+
sessionId,
|
|
323
|
+
sessionKey: this._remoteControlSessionKey,
|
|
324
|
+
duration: session.duration,
|
|
325
|
+
payload: {
|
|
326
|
+
state,
|
|
327
|
+
cause: session.cause
|
|
328
|
+
},
|
|
329
|
+
targetId: session.controlleeId,
|
|
330
|
+
keepAlive: true,
|
|
331
|
+
action: session.action
|
|
332
|
+
});
|
|
327
333
|
const nextTs = Date.now() + interval;
|
|
328
|
-
this._activeRemoteControlSession.session =
|
|
334
|
+
this._activeRemoteControlSession.session = {
|
|
335
|
+
...session,
|
|
329
336
|
nextTs
|
|
330
|
-
}
|
|
331
|
-
this.logger.info(
|
|
337
|
+
};
|
|
338
|
+
this.logger.info(`refresh remote control session schedule: ${sessionId}, next ts: ${nextTs}`);
|
|
332
339
|
} catch (e) {
|
|
333
|
-
this.logger.error(
|
|
340
|
+
this.logger.error(`ping remote control session failed: ${e}`);
|
|
334
341
|
}
|
|
335
342
|
}
|
|
336
343
|
}
|
|
337
344
|
if (this._receivedRemoteControlSession) {
|
|
338
|
-
const
|
|
339
|
-
sessionId
|
|
340
|
-
session
|
|
345
|
+
const {
|
|
346
|
+
sessionId,
|
|
347
|
+
session
|
|
348
|
+
} = this._receivedRemoteControlSession;
|
|
341
349
|
if (this._isSessionExpired({
|
|
342
350
|
duration: session.duration,
|
|
343
351
|
timestamp: session.timestamp
|
|
344
352
|
})) {
|
|
345
|
-
this.logger.info(
|
|
353
|
+
this.logger.info(`remote control session expired, removed: ${sessionId}`);
|
|
346
354
|
await this._terminateRemoteControlBestEffort(sessionId, 'terminate remote control session on received side expiry');
|
|
347
355
|
return;
|
|
348
356
|
}
|
|
349
357
|
if (session.nextTs + session.interval * KEEPALIVE_TIMEOUT_MULTIPLIER < Date.now()) {
|
|
350
358
|
await this._terminateRemoteControlBestEffort(sessionId, 'terminate remote control session on keepalive timeout');
|
|
351
359
|
if (!this._receivedRemoteControlSession) {
|
|
352
|
-
this.logger.info(
|
|
360
|
+
this.logger.info(`remote control session has not been pinged, removed: ${sessionId}`);
|
|
353
361
|
}
|
|
354
362
|
}
|
|
355
363
|
}
|
|
@@ -363,7 +371,6 @@ export class FcrRemoteControlImpl {
|
|
|
363
371
|
//@internal
|
|
364
372
|
async _rejectSession(session) {
|
|
365
373
|
try {
|
|
366
|
-
var _session$payload$caus;
|
|
367
374
|
await this._api.deletePeerSession({
|
|
368
375
|
userId: this._userId,
|
|
369
376
|
sessionId: session.sessionId,
|
|
@@ -371,7 +378,7 @@ export class FcrRemoteControlImpl {
|
|
|
371
378
|
receiverIds: [session.receiverId],
|
|
372
379
|
action: 2,
|
|
373
380
|
payload: {
|
|
374
|
-
cause:
|
|
381
|
+
cause: session.payload.cause ?? {}
|
|
375
382
|
}
|
|
376
383
|
});
|
|
377
384
|
} catch (e) {
|
|
@@ -384,35 +391,38 @@ export class FcrRemoteControlImpl {
|
|
|
384
391
|
throw generateFcrCoreClientError(ErrorModuleCode.FCR_REMOTE_CONTROL, DetailErrorCode.PEER_SESSION_ALREADY_EXISTS, 'remote control session already exists');
|
|
385
392
|
}
|
|
386
393
|
try {
|
|
387
|
-
var _params$cause;
|
|
388
394
|
const _now = Date.now();
|
|
389
|
-
const sessionId = md5(
|
|
390
|
-
const
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
}
|
|
403
|
-
|
|
395
|
+
const sessionId = md5(`${_now}`);
|
|
396
|
+
const {
|
|
397
|
+
data: {
|
|
398
|
+
interval
|
|
399
|
+
}
|
|
400
|
+
} = await this._api.updatePeerSession({
|
|
401
|
+
userId: this._userId,
|
|
402
|
+
sessionId,
|
|
403
|
+
sessionKey: this._remoteControlSessionKey,
|
|
404
|
+
duration: params.duration,
|
|
405
|
+
payload: {
|
|
406
|
+
cause: params.cause ?? {},
|
|
407
|
+
state: FcrRemoteControlState.REQUEST_RECEIVED
|
|
408
|
+
},
|
|
409
|
+
targetId: params.controlleeId,
|
|
410
|
+
keepAlive: true,
|
|
411
|
+
action: 0
|
|
412
|
+
});
|
|
404
413
|
const nextTs = _now + interval;
|
|
405
414
|
this._activeRemoteControlSession = {
|
|
406
415
|
sessionId,
|
|
407
|
-
session:
|
|
416
|
+
session: {
|
|
417
|
+
...params,
|
|
408
418
|
interval,
|
|
409
419
|
nextTs,
|
|
410
420
|
startTs: _now,
|
|
411
421
|
action: 0
|
|
412
|
-
}
|
|
422
|
+
},
|
|
413
423
|
state: FcrRemoteControlState.REQUEST_RECEIVED
|
|
414
424
|
};
|
|
415
|
-
this.logger.info(
|
|
425
|
+
this.logger.info(`remote control put into session activeRemote: ${sessionId}, next ts: ${nextTs}, remain: ${interval}ms`);
|
|
416
426
|
return sessionId;
|
|
417
427
|
} catch (e) {
|
|
418
428
|
throw generateFcrCoreServerError(DetailErrorCode.LOCAL_HTTP_REQUEST_FAILED, 'start remote control session failed');
|
|
@@ -422,34 +432,39 @@ export class FcrRemoteControlImpl {
|
|
|
422
432
|
if (!this._receivedRemoteControlSession) {
|
|
423
433
|
throw generateFcrCoreClientError(ErrorModuleCode.FCR_REMOTE_CONTROL, DetailErrorCode.UNDEFINED, 'remote control session not found');
|
|
424
434
|
}
|
|
425
|
-
const
|
|
426
|
-
session
|
|
427
|
-
sessionId
|
|
428
|
-
state
|
|
435
|
+
const {
|
|
436
|
+
session,
|
|
437
|
+
sessionId,
|
|
438
|
+
state
|
|
439
|
+
} = this._receivedRemoteControlSession;
|
|
429
440
|
if (_sessionId !== sessionId) {
|
|
430
441
|
return;
|
|
431
442
|
}
|
|
432
443
|
if (session && state === FcrRemoteControlState.REQUEST_RECEIVED) {
|
|
433
|
-
const
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
}
|
|
446
|
-
|
|
444
|
+
const {
|
|
445
|
+
data: {
|
|
446
|
+
interval
|
|
447
|
+
}
|
|
448
|
+
} = await this._api.updatePeerSession({
|
|
449
|
+
userId: this._userId,
|
|
450
|
+
sessionId,
|
|
451
|
+
sessionKey: this._remoteControlSessionKey,
|
|
452
|
+
duration: session.duration,
|
|
453
|
+
payload: {
|
|
454
|
+
cause: cause ?? {},
|
|
455
|
+
state: FcrRemoteControlState.REQUEST_ACCEPTED
|
|
456
|
+
},
|
|
457
|
+
targetId: session.controllerId,
|
|
458
|
+
keepAlive: true,
|
|
459
|
+
action: 1
|
|
460
|
+
});
|
|
447
461
|
const _now = Date.now();
|
|
448
|
-
this._receivedRemoteControlSession.session =
|
|
462
|
+
this._receivedRemoteControlSession.session = {
|
|
463
|
+
...session,
|
|
449
464
|
nextTs: _now + interval,
|
|
450
465
|
startTs: _now,
|
|
451
466
|
action: 1
|
|
452
|
-
}
|
|
467
|
+
};
|
|
453
468
|
this._receivedRemoteControlSession.state = FcrRemoteControlState.REQUEST_ACCEPTED;
|
|
454
469
|
this._notifyRemoteControlState(FcrRemoteControlState.REQUEST_ACCEPTED, {
|
|
455
470
|
sessionId,
|
|
@@ -457,7 +472,7 @@ export class FcrRemoteControlImpl {
|
|
|
457
472
|
receiverId: session.controllerId,
|
|
458
473
|
controllerId: session.controllerId,
|
|
459
474
|
controlleeId: session.controlleeId,
|
|
460
|
-
cause: cause
|
|
475
|
+
cause: cause ?? {}
|
|
461
476
|
});
|
|
462
477
|
return;
|
|
463
478
|
}
|
|
@@ -466,9 +481,10 @@ export class FcrRemoteControlImpl {
|
|
|
466
481
|
if (!this._receivedRemoteControlSession) {
|
|
467
482
|
throw generateFcrCoreClientError(ErrorModuleCode.FCR_REMOTE_CONTROL, DetailErrorCode.UNDEFINED, 'remote control session not found');
|
|
468
483
|
}
|
|
469
|
-
const
|
|
470
|
-
session
|
|
471
|
-
sessionId
|
|
484
|
+
const {
|
|
485
|
+
session,
|
|
486
|
+
sessionId
|
|
487
|
+
} = this._receivedRemoteControlSession;
|
|
472
488
|
if (_sessionId !== sessionId) {
|
|
473
489
|
return;
|
|
474
490
|
}
|
|
@@ -476,11 +492,10 @@ export class FcrRemoteControlImpl {
|
|
|
476
492
|
sessionId,
|
|
477
493
|
receiverId: session.controllerId,
|
|
478
494
|
payload: {
|
|
479
|
-
cause: cause
|
|
495
|
+
cause: cause ?? {}
|
|
480
496
|
},
|
|
481
497
|
sessionKey: this._remoteControlSessionKey
|
|
482
498
|
}).then(() => {
|
|
483
|
-
var _this$_receivedRemote4;
|
|
484
499
|
this._notifyRemoteControlState(FcrRemoteControlState.REQUEST_REJECTED, {
|
|
485
500
|
sessionId,
|
|
486
501
|
fromUserId: session.controlleeId,
|
|
@@ -489,7 +504,7 @@ export class FcrRemoteControlImpl {
|
|
|
489
504
|
controlleeId: session.controlleeId,
|
|
490
505
|
cause
|
|
491
506
|
});
|
|
492
|
-
if (sessionId ===
|
|
507
|
+
if (sessionId === this._receivedRemoteControlSession?.sessionId) {
|
|
493
508
|
this._receivedRemoteControlSession = null;
|
|
494
509
|
}
|
|
495
510
|
});
|
|
@@ -499,7 +514,7 @@ export class FcrRemoteControlImpl {
|
|
|
499
514
|
const isReceivedSession = this._receivedRemoteControlSession && this._receivedRemoteControlSession.sessionId === _sessionId;
|
|
500
515
|
const session = isActiveSession ? this._activeRemoteControlSession : isReceivedSession ? this._receivedRemoteControlSession : null;
|
|
501
516
|
if (session) {
|
|
502
|
-
const _cause = cause
|
|
517
|
+
const _cause = cause ?? {};
|
|
503
518
|
try {
|
|
504
519
|
return await this._api.deletePeerSession({
|
|
505
520
|
userId: this._userId,
|
|
@@ -521,7 +536,7 @@ export class FcrRemoteControlImpl {
|
|
|
521
536
|
controllerId: session.session.controllerId,
|
|
522
537
|
controlleeId: session.session.controlleeId
|
|
523
538
|
});
|
|
524
|
-
this.logger.info(
|
|
539
|
+
this.logger.info(`delete remote control session state: ${FcrRemoteControlState.SESSION_ENDED}, ${JSON.stringify(session)}`);
|
|
525
540
|
}
|
|
526
541
|
this._activeRemoteControlSession = null;
|
|
527
542
|
this._receivedRemoteControlSession = null;
|
|
@@ -538,7 +553,7 @@ export class FcrRemoteControlImpl {
|
|
|
538
553
|
const sessionInfo = isActiveSession ? this._activeRemoteControlSession : isReceivedSession ? this._receivedRemoteControlSession : null;
|
|
539
554
|
if (sessionInfo) {
|
|
540
555
|
if (sessionInfo.state === _state) {
|
|
541
|
-
throw generateFcrCoreClientError(ErrorModuleCode.FCR_REMOTE_CONTROL, DetailErrorCode.REMOTE_CONTROL_SESSION_STATE_NOT_MATCH,
|
|
556
|
+
throw generateFcrCoreClientError(ErrorModuleCode.FCR_REMOTE_CONTROL, DetailErrorCode.REMOTE_CONTROL_SESSION_STATE_NOT_MATCH, `on update remote control session state: ${_state} already existed`);
|
|
542
557
|
}
|
|
543
558
|
switch (_state) {
|
|
544
559
|
case FcrRemoteControlState.CONNECT_INITIALIZED:
|
|
@@ -555,33 +570,39 @@ export class FcrRemoteControlImpl {
|
|
|
555
570
|
|
|
556
571
|
//@internal
|
|
557
572
|
async _initializeRemoteControlConnection(_session, cause) {
|
|
558
|
-
const
|
|
559
|
-
|
|
560
|
-
|
|
573
|
+
const {
|
|
574
|
+
session,
|
|
575
|
+
state,
|
|
576
|
+
sessionId
|
|
577
|
+
} = _session;
|
|
561
578
|
if (state !== FcrRemoteControlState.REQUEST_ACCEPTED) {
|
|
562
579
|
throw generateFcrCoreClientError(ErrorModuleCode.FCR_REMOTE_CONTROL, DetailErrorCode.REMOTE_CONTROL_SESSION_STATE_NOT_MATCH, 'remote control session state not match for initialize connection, current state: ' + state + ', expected state: ' + FcrRemoteControlState.REQUEST_ACCEPTED);
|
|
563
580
|
}
|
|
564
581
|
const targetId = this._userId === session.controlleeId ? session.controllerId : session.controlleeId;
|
|
565
|
-
const
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
}
|
|
578
|
-
|
|
582
|
+
const {
|
|
583
|
+
data: {
|
|
584
|
+
interval
|
|
585
|
+
}
|
|
586
|
+
} = await this._api.updatePeerSession({
|
|
587
|
+
userId: this._userId,
|
|
588
|
+
sessionId,
|
|
589
|
+
sessionKey: this._remoteControlSessionKey,
|
|
590
|
+
duration: session.duration,
|
|
591
|
+
payload: {
|
|
592
|
+
cause: cause ?? {},
|
|
593
|
+
state: FcrRemoteControlState.CONNECT_INITIALIZED
|
|
594
|
+
},
|
|
595
|
+
targetId,
|
|
596
|
+
keepAlive: true,
|
|
597
|
+
action: 1
|
|
598
|
+
});
|
|
579
599
|
const _now = Date.now();
|
|
580
|
-
_session.session =
|
|
600
|
+
_session.session = {
|
|
601
|
+
...session,
|
|
581
602
|
nextTs: _now + interval,
|
|
582
603
|
startTs: _now,
|
|
583
604
|
action: 1
|
|
584
|
-
}
|
|
605
|
+
};
|
|
585
606
|
_session.state = FcrRemoteControlState.CONNECT_INITIALIZED;
|
|
586
607
|
this._notifyRemoteControlState(FcrRemoteControlState.CONNECT_INITIALIZED, {
|
|
587
608
|
sessionId,
|
|
@@ -589,40 +610,46 @@ export class FcrRemoteControlImpl {
|
|
|
589
610
|
receiverId: targetId,
|
|
590
611
|
controllerId: session.controllerId,
|
|
591
612
|
controlleeId: session.controlleeId,
|
|
592
|
-
cause: cause
|
|
613
|
+
cause: cause ?? {}
|
|
593
614
|
});
|
|
594
615
|
return;
|
|
595
616
|
}
|
|
596
617
|
|
|
597
618
|
//@internal
|
|
598
619
|
async _establishRemoteControlConnection(_session, cause) {
|
|
599
|
-
const
|
|
600
|
-
|
|
601
|
-
|
|
620
|
+
const {
|
|
621
|
+
session,
|
|
622
|
+
state,
|
|
623
|
+
sessionId
|
|
624
|
+
} = _session;
|
|
602
625
|
if (state !== FcrRemoteControlState.CONNECT_INITIALIZED) {
|
|
603
626
|
throw generateFcrCoreClientError(ErrorModuleCode.FCR_REMOTE_CONTROL, DetailErrorCode.REMOTE_CONTROL_SESSION_STATE_NOT_MATCH, 'remote control session state not match for establish connection, current state: ' + state + ', expected state: ' + FcrRemoteControlState.CONNECT_INITIALIZED);
|
|
604
627
|
}
|
|
605
628
|
const targetId = this._userId === session.controlleeId ? session.controllerId : session.controlleeId;
|
|
606
|
-
const
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
}
|
|
619
|
-
|
|
629
|
+
const {
|
|
630
|
+
data: {
|
|
631
|
+
interval
|
|
632
|
+
}
|
|
633
|
+
} = await this._api.updatePeerSession({
|
|
634
|
+
userId: this._userId,
|
|
635
|
+
sessionId,
|
|
636
|
+
sessionKey: this._remoteControlSessionKey,
|
|
637
|
+
duration: session.duration,
|
|
638
|
+
payload: {
|
|
639
|
+
cause: cause ?? {},
|
|
640
|
+
state: FcrRemoteControlState.CONNECT_ESTABLISHED
|
|
641
|
+
},
|
|
642
|
+
targetId,
|
|
643
|
+
keepAlive: true,
|
|
644
|
+
action: 1
|
|
645
|
+
});
|
|
620
646
|
const _now = Date.now();
|
|
621
|
-
_session.session =
|
|
647
|
+
_session.session = {
|
|
648
|
+
...session,
|
|
622
649
|
nextTs: _now + interval,
|
|
623
650
|
startTs: _now,
|
|
624
651
|
action: 1
|
|
625
|
-
}
|
|
652
|
+
};
|
|
626
653
|
_session.state = FcrRemoteControlState.CONNECT_ESTABLISHED;
|
|
627
654
|
this._notifyRemoteControlState(FcrRemoteControlState.CONNECT_ESTABLISHED, {
|
|
628
655
|
sessionId,
|
|
@@ -630,7 +657,7 @@ export class FcrRemoteControlImpl {
|
|
|
630
657
|
receiverId: targetId,
|
|
631
658
|
controllerId: session.controllerId,
|
|
632
659
|
controlleeId: session.controlleeId,
|
|
633
|
-
cause: cause
|
|
660
|
+
cause: cause ?? {}
|
|
634
661
|
});
|
|
635
662
|
return;
|
|
636
663
|
}
|
|
@@ -672,9 +699,4 @@ export class FcrRemoteControlImpl {
|
|
|
672
699
|
_addLogObserver() {
|
|
673
700
|
this.addObserver(generateLogObserver(this.logger, [['onRemoteControlStateChanged', ['state', 'extra']]]));
|
|
674
701
|
}
|
|
675
|
-
}
|
|
676
|
-
_FcrRemoteControlImpl = FcrRemoteControlImpl;
|
|
677
|
-
var _applyDecs$e = _applyDecs(_FcrRemoteControlImpl, [[_startRemoteControlRequestDecs, 2, "startRemoteControlRequest"], [_acceptRemoteControlRequestDecs, 2, "acceptRemoteControlRequest"], [_rejectRemoteControlRequestDecs, 2, "rejectRemoteControlRequest"], [_terminateRemoteControlDecs, 2, "terminateRemoteControl"], [_updateRemoteControlConnectionStateDecs, 2, "updateRemoteControlConnectionState"], [trace, 2, "getRemoteControlState"], [bound, 2, "_notifyRemoteControlState"]], []).e;
|
|
678
|
-
var _applyDecs$e2 = _slicedToArray(_applyDecs$e, 1);
|
|
679
|
-
_initProto = _applyDecs$e2[0];
|
|
680
|
-
_applyDecs$e;
|
|
702
|
+
}
|