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