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