fcr-core 3.8.2 → 3.9.0-alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/chat-connector/type.d.ts +40 -0
- package/lib/{chat-connection → chat-connector}/type.js +1 -1
- package/lib/engine/index.d.ts +10 -11
- package/lib/engine/index.js +63 -72
- package/lib/engine/type.d.ts +96 -0
- package/lib/engine/type.js +5 -0
- package/lib/imports.d.ts +7 -4
- package/lib/imports.js +30 -4
- package/lib/index.d.ts +3 -2
- package/lib/index.js +21 -2
- package/lib/media-control/desktop.js +12 -12
- package/lib/media-control/mobile.js +4 -0
- package/lib/media-control/type.d.ts +32 -33
- package/lib/monitor-control/index.js +3 -3
- package/lib/peer-session/index.js +14 -14
- package/lib/peer-session/type.d.ts +1 -1
- package/lib/plugins/chat/chatroom.js +417 -0
- package/lib/{chat-connection → plugins/chat}/config.d.ts +1 -0
- package/lib/{chat-connection → plugins/chat}/config.js +2 -1
- package/lib/plugins/chat/connector.d.ts +38 -0
- package/lib/{chat-connection/index.js → plugins/chat/connector.js} +181 -61
- package/lib/room-control/ability-control/index.js +5 -4
- package/lib/room-control/ability-control/type.d.ts +5 -1
- package/lib/room-control/ability-control/type.js +4 -0
- package/lib/room-control/chatroom-control/type.d.ts +44 -35
- package/lib/room-control/group-control/index.js +9 -9
- package/lib/room-control/index.js +37 -22
- package/lib/room-control/interpreter-control/index.js +7 -4
- package/lib/room-control/interpreter-control/room.js +3 -3
- package/lib/room-control/interpreter-control/types.d.ts +2 -2
- package/lib/room-control/join-before-host-waitingroom-control/index.js +3 -3
- package/lib/room-control/mainroom-control/index.js +15 -13
- package/lib/room-control/privilege-control/index.js +39 -24
- package/lib/room-control/privilege-control/type.d.ts +15 -15
- package/lib/room-control/room-connector-control/index.js +7 -5
- package/lib/room-control/room-connector-control/type.d.ts +1 -1
- package/lib/room-control/room-control-factory.d.ts +3 -3
- package/lib/room-control/room-control-factory.js +7 -7
- package/lib/room-control/room-session/index.js +17 -15
- package/lib/room-control/room-session/type.d.ts +3 -3
- package/lib/room-control/sharing-control/index.js +13 -7
- package/lib/room-control/stream-control/index.js +18 -16
- package/lib/room-control/stream-control/type.d.ts +5 -5
- package/lib/room-control/stt-control/index.js +38 -31
- package/lib/room-control/type.d.ts +19 -19
- package/lib/room-control/user-control/index.js +20 -22
- package/lib/room-control/user-control/type.d.ts +1 -1
- package/lib/room-control/waitingroom-control/index.js +11 -11
- package/lib/room-control/whiteboard-control-v1/board-window.d.ts +21 -20
- package/lib/room-control/whiteboard-control-v1/board-window.js +27 -8
- package/lib/room-control/whiteboard-control-v1/factory.js +1 -1
- package/lib/room-control/whiteboard-control-v1/index.js +26 -18
- package/lib/room-control/whiteboard-control-v1/type.d.ts +26 -25
- package/lib/room-control/whiteboard-control-v1/type.js +1 -0
- package/lib/room-control/whiteboard-control-v2/annotation-control/control.d.ts +15 -6
- package/lib/room-control/whiteboard-control-v2/annotation-control/control.js +39 -5
- package/lib/room-control/whiteboard-control-v2/annotation-control/factory.d.ts +4 -5
- package/lib/room-control/whiteboard-control-v2/annotation-control/factory.js +6 -5
- package/lib/room-control/whiteboard-control-v2/annotation-control/type.d.ts +7 -1
- package/lib/room-control/whiteboard-control-v2/base/index.d.ts +9 -8
- package/lib/room-control/whiteboard-control-v2/base/index.js +84 -42
- package/lib/room-control/whiteboard-control-v2/base/main-window.d.ts +16 -15
- package/lib/room-control/whiteboard-control-v2/base/main-window.js +23 -4
- package/lib/room-control/whiteboard-control-v2/type.d.ts +17 -17
- package/lib/room-control/whiteboard-control-v2/whiteboard-control/control.d.ts +12 -6
- package/lib/room-control/whiteboard-control-v2/whiteboard-control/control.js +64 -18
- package/lib/room-control/whiteboard-control-v2/whiteboard-control/factory.d.ts +2 -2
- package/lib/room-control/whiteboard-control-v2/whiteboard-control/factory.js +10 -10
- package/lib/room-control/whiteboard-control-v2/whiteboard-control/type.d.ts +1 -1
- package/lib/room-router/index.js +10 -7
- package/lib/room-router/type.d.ts +1 -1
- package/lib/schema.d.ts +24 -46
- package/lib/schema.js +1 -2
- package/lib/service/api.d.ts +5 -3
- package/lib/service/api.js +17 -12
- package/lib/type.d.ts +64 -45
- package/lib/type.js +76 -11
- package/lib/utilities/abortable-retry.d.ts +38 -0
- package/lib/utilities/abortable-retry.js +61 -0
- package/lib/utilities/dual-video-stream-config.d.ts +6 -0
- package/lib/utilities/dual-video-stream-config.js +25 -0
- package/lib/utilities/error-helpers.d.ts +10 -9
- package/lib/utilities/error-helpers.js +12 -11
- package/lib/utilities/error.d.ts +4 -40
- package/lib/utilities/error.js +20 -77
- package/lib/utilities/join-helper.js +2 -2
- package/lib/utilities/logger.d.ts +2 -2
- package/lib/utilities/logger.js +6 -25
- package/lib/utilities/package-info.d.ts +1 -2
- package/lib/utilities/package-info.js +4 -8
- package/lib/utilities/parameters.js +88 -15
- package/lib/utilities/validate-params.js +1 -1
- package/lib/utilities/video-encoder-config.d.ts +9 -0
- package/lib/utilities/video-encoder-config.js +109 -0
- package/lib-es/{chat-connection → chat-connector}/type.js +1 -1
- package/lib-es/engine/index.js +46 -56
- package/lib-es/engine/type.js +1 -0
- package/lib-es/imports.js +5 -3
- package/lib-es/index.js +2 -1
- package/lib-es/media-control/desktop.js +12 -12
- package/lib-es/media-control/mobile.js +4 -0
- package/lib-es/monitor-control/index.js +3 -3
- package/lib-es/peer-session/index.js +16 -15
- package/lib-es/plugins/chat/chatroom.js +409 -0
- package/lib-es/{chat-connection → plugins/chat}/config.js +2 -1
- package/lib-es/{chat-connection/index.js → plugins/chat/connector.js} +178 -58
- package/lib-es/room-control/ability-control/index.js +5 -4
- package/lib-es/room-control/ability-control/type.js +4 -0
- package/lib-es/room-control/group-control/index.js +11 -10
- package/lib-es/room-control/index.js +40 -26
- package/lib-es/room-control/interpreter-control/index.js +10 -5
- package/lib-es/room-control/interpreter-control/room.js +3 -3
- package/lib-es/room-control/join-before-host-waitingroom-control/index.js +4 -3
- package/lib-es/room-control/mainroom-control/index.js +16 -17
- package/lib-es/room-control/privilege-control/index.js +43 -29
- package/lib-es/room-control/room-connector-control/index.js +9 -6
- package/lib-es/room-control/room-control-factory.js +6 -6
- package/lib-es/room-control/room-session/index.js +21 -22
- package/lib-es/room-control/sharing-control/index.js +13 -7
- package/lib-es/room-control/stream-control/index.js +21 -18
- package/lib-es/room-control/stt-control/index.js +23 -15
- package/lib-es/room-control/user-control/index.js +23 -23
- package/lib-es/room-control/waitingroom-control/index.js +10 -9
- package/lib-es/room-control/whiteboard-control-v1/board-window.js +27 -8
- package/lib-es/room-control/whiteboard-control-v1/factory.js +1 -1
- package/lib-es/room-control/whiteboard-control-v1/index.js +26 -17
- package/lib-es/room-control/whiteboard-control-v1/type.js +1 -0
- package/lib-es/room-control/whiteboard-control-v2/annotation-control/control.js +39 -5
- package/lib-es/room-control/whiteboard-control-v2/annotation-control/factory.js +7 -6
- package/lib-es/room-control/whiteboard-control-v2/base/index.js +86 -42
- package/lib-es/room-control/whiteboard-control-v2/base/main-window.js +23 -4
- package/lib-es/room-control/whiteboard-control-v2/whiteboard-control/control.js +60 -13
- package/lib-es/room-control/whiteboard-control-v2/whiteboard-control/factory.js +10 -10
- package/lib-es/room-router/index.js +10 -6
- package/lib-es/schema.js +1 -2
- package/lib-es/service/api.js +17 -12
- package/lib-es/type.js +70 -18
- package/lib-es/utilities/abortable-retry.js +54 -0
- package/lib-es/utilities/dual-video-stream-config.js +19 -0
- package/lib-es/utilities/error-helpers.js +13 -12
- package/lib-es/utilities/error.js +9 -75
- package/lib-es/utilities/join-helper.js +4 -3
- package/lib-es/utilities/logger.js +7 -23
- package/lib-es/utilities/package-info.js +4 -6
- package/lib-es/utilities/parameters.js +88 -15
- package/lib-es/utilities/validate-params.js +3 -2
- package/lib-es/utilities/video-encoder-config.js +103 -0
- package/package.json +7 -7
- package/lib/chat-connection/index.d.ts +0 -24
- package/lib/chat-connection/type.d.ts +0 -17
- package/lib/plugins/chatroom.js +0 -454
- package/lib/room-control/chatroom-control/config.d.ts +0 -51
- package/lib/room-control/chatroom-control/config.js +0 -105
- package/lib/utilities/storage.d.ts +0 -8
- package/lib/utilities/storage.js +0 -33
- package/lib-es/plugins/chatroom.js +0 -446
- package/lib-es/room-control/chatroom-control/config.js +0 -100
- package/lib-es/utilities/storage.js +0 -27
- /package/lib/plugins/{chatroom.d.ts → chat/chatroom.d.ts} +0 -0
package/lib-es/engine/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import "core-js/modules/es.array.push.js";
|
|
1
2
|
import "core-js/modules/esnext.function.metadata.js";
|
|
2
3
|
import "core-js/modules/esnext.map.delete-all.js";
|
|
3
4
|
import "core-js/modules/esnext.map.emplace.js";
|
|
@@ -14,8 +15,7 @@ import "core-js/modules/esnext.map.reduce.js";
|
|
|
14
15
|
import "core-js/modules/esnext.map.some.js";
|
|
15
16
|
import "core-js/modules/esnext.map.update.js";
|
|
16
17
|
import "core-js/modules/esnext.symbol.metadata.js";
|
|
17
|
-
let _initProto, _createMainRoomControlDecs, _createWaitingRoomControlDecs, _createRoomRouterDecs, _createRoomControlAndJoinDecs, _sendPeerMessageDecs, _setParametersDecs;
|
|
18
|
-
import "core-js/modules/es.array.push.js";
|
|
18
|
+
let _initProto, _renewUserTokenDecs, _createMainRoomControlDecs, _createWaitingRoomControlDecs, _createRoomRouterDecs, _createRoomControlAndJoinDecs, _sendPeerMessageDecs, _setParametersDecs;
|
|
19
19
|
import "core-js/modules/es.json.stringify.js";
|
|
20
20
|
import "core-js/modules/esnext.iterator.constructor.js";
|
|
21
21
|
import "core-js/modules/esnext.iterator.map.js";
|
|
@@ -24,39 +24,44 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
24
24
|
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); }
|
|
25
25
|
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; }
|
|
26
26
|
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; }
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
30
|
-
import {
|
|
27
|
+
import { trace } from 'agora-foundation/lib/decorator';
|
|
28
|
+
import { retryAttempt } from 'agora-foundation/lib/utilities/async-retry';
|
|
29
|
+
import { getPlatform } from 'agora-foundation/lib/utilities/env';
|
|
30
|
+
import { ErrorModuleCode } from 'agora-foundation/lib/utilities/error/error-code';
|
|
31
|
+
import { AgoraObservable } from 'agora-foundation/lib/utilities/observable';
|
|
32
|
+
import { Mutex } from 'agora-foundation/lib/worker/mutex';
|
|
33
|
+
import { AgoraRestfulClientImpl, AgoraRteEngine, convertStreamTypeToPublishState } from 'agora-rte-sdk';
|
|
34
|
+
import { AgoraRtcRegion } from 'agora-rte-sdk/lib/core/rtc/type';
|
|
35
|
+
import { AgoraRtmRegion } from 'agora-rte-sdk/lib/core/rtm/type';
|
|
36
|
+
import { getSharedDomainHolder, resetSharedDomainHolder } from 'agora-rte-sdk/lib/core/services/domain-holder';
|
|
37
|
+
import to from 'await-to-js';
|
|
38
|
+
import { FcrConnectionState } from '..';
|
|
31
39
|
import { FcrDesktopMediaControlImpl } from '../media-control/desktop';
|
|
40
|
+
import { FcrMobileMediaControlImpl } from '../media-control/mobile';
|
|
41
|
+
import { FcrMonitorControlImpl } from '../monitor-control';
|
|
32
42
|
import { FcrPeerSessionControlImpl } from '../peer-session';
|
|
33
|
-
import {
|
|
34
|
-
import {
|
|
35
|
-
import { FcrErrorModuleCode, FcrError, handleRequestError, ERROR_CODES_NOT_RETRYABLE_WHEN_JOINING_ROOM } from '../utilities/error';
|
|
36
|
-
import { CMD_PEER_MESSAGE } from '../utilities/cmd';
|
|
37
|
-
import { FcrRoomType } from '../room-control/type';
|
|
38
|
-
import { FcrChatConnectionImpl } from '../chat-connection';
|
|
43
|
+
import { FcrChatRoomControlImpl } from '../plugins/chat/chatroom';
|
|
44
|
+
import { FcrChatConnectorImpl } from '../plugins/chat/connector';
|
|
39
45
|
import { FcrMainRoomControlImpl } from '../room-control/mainroom-control';
|
|
46
|
+
import { FcrSharedCache } from '../room-control/shared-cache';
|
|
47
|
+
import { FcrRoomType } from '../room-control/type';
|
|
40
48
|
import { FcrWaitingRoomControlImpl } from '../room-control/waitingroom-control';
|
|
41
|
-
import {
|
|
42
|
-
import {
|
|
43
|
-
import {
|
|
44
|
-
import {
|
|
45
|
-
import {
|
|
46
|
-
import {
|
|
49
|
+
import { FcrRoomRouterImpl } from '../room-router';
|
|
50
|
+
import { booleanSchema, fcrRoomJoinOptionsSchema, stringKeyUnknownValueSchema, stringSchema } from '../schema';
|
|
51
|
+
import { FcrCoreServiceApi } from '../service/api';
|
|
52
|
+
import { FcrReturnCode, FcrUserRoleToStringMap } from '../type';
|
|
53
|
+
import { CMD_PEER_MESSAGE } from '../utilities/cmd';
|
|
54
|
+
import { ERROR_CODES_NOT_RETRYABLE_WHEN_JOINING_ROOM, FcrError, handleRequestError } from '../utilities/error';
|
|
47
55
|
import { createLogger, generateLogObserver } from '../utilities/logger';
|
|
56
|
+
import { getDependenciesInfo, getVersion } from '../utilities/package-info';
|
|
57
|
+
import { getCoreIpList, getEasemobChatIpList, getEasemobRestIpList, isEndpointRegionDisabled } from '../utilities/parameters';
|
|
48
58
|
import validateParams from '../utilities/validate-params';
|
|
49
|
-
|
|
50
|
-
import { AgoraRteError } from 'agora-rte-sdk/lib/core/utilities/error';
|
|
51
|
-
import { FcrRoomRouterImpl } from '../room-router';
|
|
52
|
-
import { FcrSharedCache } from '../room-control/shared-cache';
|
|
53
|
-
import { getDependenciesInfo } from '../utilities/package-info';
|
|
54
|
-
export class FcrCoreEngine {
|
|
59
|
+
export class FcrCoreEngineImpl {
|
|
55
60
|
static {
|
|
56
|
-
[_initProto] = _applyDecs(this, [[trace, 2, "release"], [trace, 2, "login"], [trace, 2, "logout"], [
|
|
61
|
+
[_initProto] = _applyDecs(this, [[trace, 2, "release"], [trace, 2, "login"], [trace, 2, "logout"], [_renewUserTokenDecs, 2, "renewUserToken"], [trace, 2, "getVersion"], [_createMainRoomControlDecs, 2, "createMainRoomControl"], [_createWaitingRoomControlDecs, 2, "createWaitingRoomControl"], [_createRoomRouterDecs, 2, "createRoomRouter"], [_createRoomControlAndJoinDecs, 2, "createRoomControlAndJoin"], [trace, 2, "getDesktopMediaControl"], [trace, 2, "getMobileMediaControl"], [trace, 2, "getMonitorControl"], [trace, 2, "getPeerSessionControl"], [_sendPeerMessageDecs, 2, "sendPeerMessage"], [_setParametersDecs, 2, "setParameters"]], []).e;
|
|
57
62
|
}
|
|
58
63
|
// @internal
|
|
59
|
-
[(_createMainRoomControlDecs = [trace, validateParams(stringSchema)], _createWaitingRoomControlDecs = [trace, validateParams(stringSchema)], _createRoomRouterDecs = [trace, validateParams(stringSchema)], _createRoomControlAndJoinDecs = [trace, validateParams(stringSchema, fcrRoomJoinOptionsSchema)], _sendPeerMessageDecs = [trace, validateParams(stringKeyUnknownValueSchema, booleanSchema, stringSchema)], _setParametersDecs = [trace, validateParams(stringKeyUnknownValueSchema)], "logger")] = (_initProto(this), createLogger({
|
|
64
|
+
[(_renewUserTokenDecs = trace(['token'], true), _createMainRoomControlDecs = [trace(['roomId']), validateParams(stringSchema)], _createWaitingRoomControlDecs = [trace(['roomId']), validateParams(stringSchema)], _createRoomRouterDecs = [trace(['roomId']), validateParams(stringSchema)], _createRoomControlAndJoinDecs = [trace(['roomId', 'options']), validateParams(stringSchema, fcrRoomJoinOptionsSchema)], _sendPeerMessageDecs = [trace(['payload', 'guaranteedDelivery', 'receiverId'], true), validateParams(stringKeyUnknownValueSchema, booleanSchema, stringSchema)], _setParametersDecs = [trace(['parameters'], true), validateParams(stringKeyUnknownValueSchema)], "logger")] = (_initProto(this), createLogger({
|
|
60
65
|
prefix: 'FcrCoreEngine'
|
|
61
66
|
}));
|
|
62
67
|
// @internal
|
|
@@ -89,7 +94,6 @@ export class FcrCoreEngine {
|
|
|
89
94
|
this._config = config;
|
|
90
95
|
resetSharedDomainHolder();
|
|
91
96
|
this.logger.info('Fcr core engine is created, version: ', this.getVersion());
|
|
92
|
-
const parameters = this._presetParameters(config.parameters);
|
|
93
97
|
this._rteEngine = new AgoraRteEngine({
|
|
94
98
|
appId: config.appId,
|
|
95
99
|
userId: config.userId,
|
|
@@ -103,9 +107,10 @@ export class FcrCoreEngine {
|
|
|
103
107
|
},
|
|
104
108
|
dualCameraVideoStreamConfig: config.dualCameraVideoStreamConfig,
|
|
105
109
|
dualScreenVideoStreamConfig: config.dualScreenVideoStreamConfig,
|
|
106
|
-
parameters: parameters
|
|
110
|
+
parameters: config.parameters
|
|
107
111
|
});
|
|
108
|
-
|
|
112
|
+
const domainHolder = getSharedDomainHolder(config.region);
|
|
113
|
+
this._restfulClient = new AgoraRestfulClientImpl(this._rteEngine.getHttpAuthHeadersProvider(), domainHolder, this._rteEngine.getRequestScheduler());
|
|
109
114
|
this._apiService = new FcrCoreServiceApi(this._restfulClient, config.appId, config.region, !isEndpointRegionDisabled(config.parameters));
|
|
110
115
|
|
|
111
116
|
// cannot be lazy loaded, because all the observers should be added before the engine is started
|
|
@@ -125,6 +130,7 @@ export class FcrCoreEngine {
|
|
|
125
130
|
*/
|
|
126
131
|
release() {
|
|
127
132
|
this._rteEngine.release();
|
|
133
|
+
return FcrReturnCode.SUCCESS;
|
|
128
134
|
}
|
|
129
135
|
|
|
130
136
|
/**
|
|
@@ -133,12 +139,12 @@ export class FcrCoreEngine {
|
|
|
133
139
|
async login() {
|
|
134
140
|
await this._lock.dispatch(async () => {
|
|
135
141
|
if (this._isLoggingIn) {
|
|
136
|
-
return;
|
|
142
|
+
return FcrReturnCode.UNDEFINED;
|
|
137
143
|
}
|
|
138
144
|
try {
|
|
139
145
|
this._isLoggingIn = true;
|
|
140
146
|
this._chatConnection.login();
|
|
141
|
-
await this._rteEngine.login();
|
|
147
|
+
return await this._rteEngine.login();
|
|
142
148
|
} finally {
|
|
143
149
|
this._isLoggingIn = false;
|
|
144
150
|
this._rteEngine.getMonitor().uploadLog({
|
|
@@ -155,7 +161,7 @@ export class FcrCoreEngine {
|
|
|
155
161
|
await this._lock.dispatch(async () => {
|
|
156
162
|
this._isLoggingIn = false;
|
|
157
163
|
this._chatConnection.logout();
|
|
158
|
-
await this._rteEngine.logout();
|
|
164
|
+
return await this._rteEngine.logout();
|
|
159
165
|
});
|
|
160
166
|
}
|
|
161
167
|
/**
|
|
@@ -163,7 +169,7 @@ export class FcrCoreEngine {
|
|
|
163
169
|
* @param token
|
|
164
170
|
*/
|
|
165
171
|
renewUserToken(token) {
|
|
166
|
-
this._rteEngine.renewUserToken(token);
|
|
172
|
+
return this._rteEngine.renewUserToken(token);
|
|
167
173
|
}
|
|
168
174
|
|
|
169
175
|
/**
|
|
@@ -247,7 +253,7 @@ export class FcrCoreEngine {
|
|
|
247
253
|
version: getVersion(),
|
|
248
254
|
password: options.password,
|
|
249
255
|
avatar: options.avatar
|
|
250
|
-
}),
|
|
256
|
+
}), ErrorModuleCode.FCR_ENGINE);
|
|
251
257
|
const {
|
|
252
258
|
data,
|
|
253
259
|
ts
|
|
@@ -270,7 +276,7 @@ export class FcrCoreEngine {
|
|
|
270
276
|
timeFn,
|
|
271
277
|
currentRetry
|
|
272
278
|
}) => {
|
|
273
|
-
if (
|
|
279
|
+
if (error instanceof FcrError && ERROR_CODES_NOT_RETRYABLE_WHEN_JOINING_ROOM.includes(error.code)) {
|
|
274
280
|
throw error;
|
|
275
281
|
}
|
|
276
282
|
this.logger.error(`retry to join room, ${error.message}, retry ${currentRetry} times`);
|
|
@@ -323,7 +329,7 @@ export class FcrCoreEngine {
|
|
|
323
329
|
* @param receiverId
|
|
324
330
|
*/
|
|
325
331
|
async sendPeerMessage(payload, guaranteedDelivery, receiverId) {
|
|
326
|
-
await this._rteEngine.sendPeerMessage(payload, `${CMD_PEER_MESSAGE}`, guaranteedDelivery, receiverId);
|
|
332
|
+
return await this._rteEngine.sendPeerMessage(payload, `${CMD_PEER_MESSAGE}`, guaranteedDelivery, receiverId);
|
|
327
333
|
}
|
|
328
334
|
|
|
329
335
|
/**
|
|
@@ -339,13 +345,14 @@ export class FcrCoreEngine {
|
|
|
339
345
|
rtc,
|
|
340
346
|
rtm
|
|
341
347
|
} = parameters;
|
|
342
|
-
this._rteEngine.setParameters({
|
|
348
|
+
return this._rteEngine.setParameters({
|
|
343
349
|
rtc,
|
|
344
350
|
rtm,
|
|
345
351
|
rte
|
|
346
352
|
});
|
|
347
353
|
} catch (e) {
|
|
348
354
|
this.logger.warn('setParameters failed', e);
|
|
355
|
+
return FcrReturnCode.UNDEFINED;
|
|
349
356
|
}
|
|
350
357
|
}
|
|
351
358
|
|
|
@@ -377,7 +384,7 @@ export class FcrCoreEngine {
|
|
|
377
384
|
});
|
|
378
385
|
}
|
|
379
386
|
_addLogObserver() {
|
|
380
|
-
this.addObserver(generateLogObserver(this.logger, ['onConnectionStateUpdated', 'onPeerMessageReceived', 'onUserTokenWillExpire']));
|
|
387
|
+
this.addObserver(generateLogObserver(this.logger, [['onConnectionStateUpdated', ['state']], ['onPeerMessageReceived', ['message']], 'onUserTokenWillExpire']));
|
|
381
388
|
}
|
|
382
389
|
_setupCoreIpList(parameters) {
|
|
383
390
|
const coreIpList = getCoreIpList(parameters);
|
|
@@ -400,23 +407,6 @@ export class FcrCoreEngine {
|
|
|
400
407
|
_createChatConnection(parameters) {
|
|
401
408
|
const chatIpList = getEasemobChatIpList(parameters);
|
|
402
409
|
const restIpList = getEasemobRestIpList(parameters);
|
|
403
|
-
return new
|
|
404
|
-
}
|
|
405
|
-
_presetParameters(parameters) {
|
|
406
|
-
if (!parameters) {
|
|
407
|
-
parameters = {
|
|
408
|
-
rtc: getRtcPresetParameters()
|
|
409
|
-
};
|
|
410
|
-
} else if (!parameters.rtc) {
|
|
411
|
-
parameters.rtc = getRtcPresetParameters();
|
|
412
|
-
} else {
|
|
413
|
-
parameters.rtc = this._mergeRtcPresetParameters(parameters.rtc);
|
|
414
|
-
}
|
|
415
|
-
return parameters;
|
|
416
|
-
}
|
|
417
|
-
_mergeRtcPresetParameters(parametersList) {
|
|
418
|
-
const rtcPresetParameters = getRtcPresetParameters();
|
|
419
|
-
parametersList.push(...rtcPresetParameters);
|
|
420
|
-
return parametersList;
|
|
410
|
+
return new FcrChatConnectorImpl(this._config.userId, this._apiService, chatIpList, restIpList);
|
|
421
411
|
}
|
|
422
412
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/lib-es/imports.js
CHANGED
|
@@ -36,7 +36,7 @@ export { Mutex } from 'agora-foundation/lib/worker/mutex';
|
|
|
36
36
|
// Agora RTE exports
|
|
37
37
|
|
|
38
38
|
export { AgoraRteError } from 'agora-rte-sdk/lib/core/utilities/error';
|
|
39
|
-
export { AgoraError as FcrError } from 'agora-foundation/lib/utilities/agora-error';
|
|
39
|
+
export { AgoraError as FcrError } from 'agora-foundation/lib/utilities/error/agora-error';
|
|
40
40
|
export { AgoraRteConnectionState, AgoraRteEngine, convertStreamTypeToPublishState, AgoraRteLatencyLevel } from 'agora-rte-sdk';
|
|
41
41
|
export { AgoraRteRoomConnectorType, AgoraRteStreamPrivilegeOperation, AgoraRteStreamPrivilegeVideoSourceType, AgoraRteStreamPrivilegeAudioSourceType, AgoraRteMediaStreamType } from 'agora-rte-sdk/lib/core/scene/type';
|
|
42
42
|
export { AgoraRtcRegion, AgoraRtcVideoSourceType, AgoraRtcAudioSourceType, AgoraRtcMediaSourceState, AgoraRtcRenderMode, AgoraRtcVideoStreamType, AgoraRtcCapability, AgoraRtcAiDenoiseLevel, AgoraRtcAudioOutputRouting, AgoraRtcLatencyLevelType, AgoraRtcEncryptionMode } from 'agora-rte-sdk/lib/core/rtc/type';
|
|
@@ -47,11 +47,13 @@ export { getSharedDomainHolder } from 'agora-rte-sdk/lib/core/services/domain-ho
|
|
|
47
47
|
export { AgoraRteScreenCaptureType, AgoraRteVideoOrientation } from 'agora-rte-sdk/lib/core/media/type';
|
|
48
48
|
export { registerPlugin } from 'agora-rte-sdk/lib/core/engine/plugin';
|
|
49
49
|
export { AgoraRteUserUpdatedReason } from 'agora-rte-sdk/lib/core/scene/type';
|
|
50
|
-
export {
|
|
50
|
+
export { LoggerManager } from 'agora-foundation/lib/utilities/logger';
|
|
51
51
|
export { FcrWhiteboardControlFactoryImpl } from './room-control/whiteboard-control-v2/whiteboard-control/factory';
|
|
52
52
|
export { FcrAnnotationControlFactoryImpl } from './room-control/whiteboard-control-v2/annotation-control/factory';
|
|
53
53
|
export { deCompressGzipToJson } from './room-control/stt-control/de-compress-gzip';
|
|
54
54
|
export { getVersion } from './utilities/package-info';
|
|
55
55
|
export const localStorage = window.localStorage;
|
|
56
56
|
export { v4 } from 'uuid';
|
|
57
|
-
export { default as merge } from 'lodash/merge';
|
|
57
|
+
export { default as merge } from 'lodash/merge';
|
|
58
|
+
export { DetailErrorCode, ErrorModuleCode, ErrorServiceType } from 'agora-foundation/lib/utilities/error/error-code';
|
|
59
|
+
export { FcrChatRoomControlImpl } from './plugins/chat/chatroom';
|
package/lib-es/index.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
// types
|
|
2
2
|
|
|
3
3
|
//enums
|
|
4
|
-
export { FcrStreamLatencyLevel, FcrPermissionAction, FcrPrivilegeUserRole, FcrUserRole, FcrStreamState, FcrRegion, FcrStreamType, FcrUserUpdatedReason, FcrRoomConnectorType, FcrVideoSourceType, FcrAudioSourceType, FcrMediaSourceState, FcrVideoRenderMode, FcrVideoStreamType, FcrCapability, FcrAiDenoiseLevel, FcrStreamPrivilegeOperation, FcrStreamPrivilegeVideoSourceType, FcrStreamPrivilegeAudioSourceType, FcrConnectionState,
|
|
4
|
+
export { FcrStreamLatencyLevel, FcrPermissionAction, FcrPrivilegeUserRole, FcrUserRole, FcrStreamState, FcrRegion, FcrStreamType, FcrUserUpdatedReason, FcrRoomConnectorType, FcrVideoSourceType, FcrAudioSourceType, FcrMediaSourceState, FcrVideoRenderMode, FcrVideoStreamType, FcrCapability, FcrAiDenoiseLevel, FcrStreamPrivilegeOperation, FcrStreamPrivilegeVideoSourceType, FcrStreamPrivilegeAudioSourceType, FcrConnectionState, registerPlugin, FcrBoardToolType, FcrBoardShape, FcrCoreEngineConfig, FcrVideoEncoderConfig, FcrDualVideoStreamConfig } from './type';
|
|
5
|
+
export { FcrCoreEngineImpl as FcrCoreEngine } from './engine';
|
|
5
6
|
|
|
6
7
|
// classes
|
|
7
8
|
export { FcrError } from './type';
|
|
@@ -15,7 +15,7 @@ import "core-js/modules/esnext.map.reduce.js";
|
|
|
15
15
|
import "core-js/modules/esnext.map.some.js";
|
|
16
16
|
import "core-js/modules/esnext.map.update.js";
|
|
17
17
|
import "core-js/modules/esnext.symbol.metadata.js";
|
|
18
|
-
let _initProto, _getCameraTrackDecs, _getMicrophoneTrackDecs, _getScreenTrackDecs, _getLoopbackTrackDecs, _setSelectedSpeakerDecs, _startSelectedSpeakerTestDecs, _isCapabilitySupportedDecs, _adjustOutputVolumeDecs, _setSelectedSpeakerVolumeDecs;
|
|
18
|
+
let _initProto, _getCameraTrackDecs, _getMicrophoneTrackDecs, _getScreenTrackDecs, _getLoopbackTrackDecs, _setSelectedSpeakerDecs, _startSelectedSpeakerTestDecs, _stopSelectedSpeakerTestDecs, _isCapabilitySupportedDecs, _adjustOutputVolumeDecs, _setSelectedSpeakerVolumeDecs, _observeSystemSelectedSpeakerChangedDecs, _observeSystemSelectedMicrophoneChangedDecs, _disableAGCDecs, _enableAGCDecs;
|
|
19
19
|
import "core-js/modules/esnext.iterator.constructor.js";
|
|
20
20
|
import "core-js/modules/esnext.iterator.for-each.js";
|
|
21
21
|
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)]; } }; }
|
|
@@ -32,16 +32,16 @@ import { createLogger, generateLogObserver } from '../utilities/logger';
|
|
|
32
32
|
*/
|
|
33
33
|
export class FcrDesktopMediaControlImpl {
|
|
34
34
|
static {
|
|
35
|
-
[_initProto] = _applyDecs(this, [[trace, 2, "getLoopbackList"], [trace, 2, "getCameraList"], [trace, 2, "getMicrophoneList"], [trace, 2, "getSpeakerList"], [trace, 2, "getSystemSelectedMicrophone"], [trace, 2, "getSystemSelectedSpeaker"], [trace, 2, "getWindowList"], [trace, 2, "getDisplayList"], [_getCameraTrackDecs, 2, "getCameraTrack"], [_getMicrophoneTrackDecs, 2, "getMicrophoneTrack"], [_getScreenTrackDecs, 2, "getScreenTrack"], [_getLoopbackTrackDecs, 2, "getLoopbackTrack"], [_setSelectedSpeakerDecs, 2, "setSelectedSpeaker"], [_startSelectedSpeakerTestDecs, 2, "startSelectedSpeakerTest"], [
|
|
35
|
+
[_initProto] = _applyDecs(this, [[trace, 2, "getLoopbackList"], [trace, 2, "getCameraList"], [trace, 2, "getMicrophoneList"], [trace, 2, "getSpeakerList"], [trace, 2, "getSystemSelectedMicrophone"], [trace, 2, "getSystemSelectedSpeaker"], [trace, 2, "getWindowList"], [trace, 2, "getDisplayList"], [_getCameraTrackDecs, 2, "getCameraTrack"], [_getMicrophoneTrackDecs, 2, "getMicrophoneTrack"], [_getScreenTrackDecs, 2, "getScreenTrack"], [_getLoopbackTrackDecs, 2, "getLoopbackTrack"], [_setSelectedSpeakerDecs, 2, "setSelectedSpeaker"], [_startSelectedSpeakerTestDecs, 2, "startSelectedSpeakerTest"], [_stopSelectedSpeakerTestDecs, 2, "stopSelectedSpeakerTest"], [_isCapabilitySupportedDecs, 2, "isCapabilitySupported"], [_adjustOutputVolumeDecs, 2, "adjustOutputVolume"], [_setSelectedSpeakerVolumeDecs, 2, "setSelectedSpeakerVolume"], [trace, 2, "getSelectedSpeakerVolume"], [_observeSystemSelectedSpeakerChangedDecs, 2, "observeSystemSelectedSpeakerChanged"], [_observeSystemSelectedMicrophoneChangedDecs, 2, "observeSystemSelectedMicrophoneChanged"], [_disableAGCDecs, 2, "disableAGC"], [_enableAGCDecs, 2, "enableAGC"]], []).e;
|
|
36
36
|
}
|
|
37
|
-
[(_getCameraTrackDecs = [trace, validateParams(stringSchema)], _getMicrophoneTrackDecs = [trace, validateParams(stringSchema)], _getScreenTrackDecs = [trace, validateParams(stringSchema)], _getLoopbackTrackDecs = [trace, validateParams(stringSchema)], _setSelectedSpeakerDecs = [trace, validateParams(stringSchema)], _startSelectedSpeakerTestDecs = [trace, validateParams(stringSchema)], _isCapabilitySupportedDecs = [trace, validateParams(fcrCapabilitySchema)], _adjustOutputVolumeDecs = [trace, validateParams(numberSchema)], _setSelectedSpeakerVolumeDecs = [trace, validateParams(numberSchema)], "logger")] = (_initProto(this), createLogger({
|
|
37
|
+
[(_getCameraTrackDecs = [trace(['deviceId']), validateParams(stringSchema)], _getMicrophoneTrackDecs = [trace(['deviceId']), validateParams(stringSchema)], _getScreenTrackDecs = [trace(['sourceId']), validateParams(stringSchema)], _getLoopbackTrackDecs = [trace(['sourceId']), validateParams(stringSchema)], _setSelectedSpeakerDecs = [trace(['deviceId'], true), validateParams(stringSchema)], _startSelectedSpeakerTestDecs = [trace(['url'], true), validateParams(stringSchema)], _stopSelectedSpeakerTestDecs = trace(true), _isCapabilitySupportedDecs = [trace(['capability']), validateParams(fcrCapabilitySchema)], _adjustOutputVolumeDecs = [trace(['volume'], true), validateParams(numberSchema)], _setSelectedSpeakerVolumeDecs = [trace(['volume'], true), validateParams(numberSchema)], _observeSystemSelectedSpeakerChangedDecs = trace(true), _observeSystemSelectedMicrophoneChangedDecs = trace(true), _disableAGCDecs = trace(true), _enableAGCDecs = trace(true), "logger")] = (_initProto(this), createLogger({
|
|
38
38
|
prefix: 'FcrDesktopMediaControlImpl'
|
|
39
39
|
}));
|
|
40
40
|
_observable = new AgoraObservable();
|
|
41
|
-
_cameraLogObserver = generateLogObserver(this.logger, ['onCameraStateUpdated']);
|
|
42
|
-
_microphoneLogObserver = generateLogObserver(this.logger, ['onMicrophoneStateUpdated']);
|
|
43
|
-
_screenLogObserver = generateLogObserver(this.logger, ['onScreenCaptureStateUpdated']);
|
|
44
|
-
_loopbackLogObserver = generateLogObserver(this.logger, ['onLoopbackRecordingStateUpdated']);
|
|
41
|
+
_cameraLogObserver = generateLogObserver(this.logger, [['onCameraStateUpdated', ['deviceId', 'state']]]);
|
|
42
|
+
_microphoneLogObserver = generateLogObserver(this.logger, [['onMicrophoneStateUpdated', ['deviceId', 'state']]]);
|
|
43
|
+
_screenLogObserver = generateLogObserver(this.logger, [['onScreenCaptureStateUpdated', ['sourceId', 'state']]]);
|
|
44
|
+
_loopbackLogObserver = generateLogObserver(this.logger, [['onLoopbackRecordingStateUpdated', ['deviceId', 'state']]]);
|
|
45
45
|
constructor(mediaControl) {
|
|
46
46
|
this._mediaControl = mediaControl;
|
|
47
47
|
this._mediaControl.addObserver({
|
|
@@ -131,22 +131,22 @@ export class FcrDesktopMediaControlImpl {
|
|
|
131
131
|
return track;
|
|
132
132
|
}
|
|
133
133
|
setSelectedSpeaker(deviceId) {
|
|
134
|
-
this._mediaControl.setSelectedSpeaker(deviceId);
|
|
134
|
+
return this._mediaControl.setSelectedSpeaker(deviceId);
|
|
135
135
|
}
|
|
136
136
|
startSelectedSpeakerTest(url) {
|
|
137
|
-
this._mediaControl.startSpeakerTest(url);
|
|
137
|
+
return this._mediaControl.startSpeakerTest(url);
|
|
138
138
|
}
|
|
139
139
|
stopSelectedSpeakerTest() {
|
|
140
|
-
this._mediaControl.stopSpeakerTest();
|
|
140
|
+
return this._mediaControl.stopSpeakerTest();
|
|
141
141
|
}
|
|
142
142
|
isCapabilitySupported(capability) {
|
|
143
143
|
return this._mediaControl.isCapabilitySupported(capability);
|
|
144
144
|
}
|
|
145
145
|
adjustOutputVolume(volume) {
|
|
146
|
-
this._mediaControl.adjustAudioOutputVolume(volume);
|
|
146
|
+
return this._mediaControl.adjustAudioOutputVolume(volume);
|
|
147
147
|
}
|
|
148
148
|
setSelectedSpeakerVolume(volume) {
|
|
149
|
-
this._mediaControl.setSelectedSpeakerVolume(volume);
|
|
149
|
+
return this._mediaControl.setSelectedSpeakerVolume(volume);
|
|
150
150
|
}
|
|
151
151
|
getSelectedSpeakerVolume() {
|
|
152
152
|
return this._mediaControl.getSelectedSpeakerVolume();
|
|
@@ -120,6 +120,10 @@ export class FcrMobileMediaControlImpl {
|
|
|
120
120
|
stopScreenCapture() {
|
|
121
121
|
this._mediaControl.getScreenTrack(this._screenDeviceName).stop();
|
|
122
122
|
}
|
|
123
|
+
startScreenCaptureWithParams(params) {
|
|
124
|
+
this._mediaControl.getScreenTrack(this._screenDeviceName).setCaptureParams(params);
|
|
125
|
+
this._mediaControl.getScreenTrack(this._screenDeviceName).start(AgoraRteScreenCaptureType.SCREEN, []);
|
|
126
|
+
}
|
|
123
127
|
getScreenCaptureState() {
|
|
124
128
|
return this._mediaControl.getScreenTrack(this._screenDeviceName).getState();
|
|
125
129
|
}
|
|
@@ -15,7 +15,7 @@ import "core-js/modules/esnext.map.reduce.js";
|
|
|
15
15
|
import "core-js/modules/esnext.map.some.js";
|
|
16
16
|
import "core-js/modules/esnext.map.update.js";
|
|
17
17
|
import "core-js/modules/esnext.symbol.metadata.js";
|
|
18
|
-
let _initProto;
|
|
18
|
+
let _initProto, _uploadEventDecs;
|
|
19
19
|
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)]; } }; }
|
|
20
20
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
21
21
|
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); }
|
|
@@ -27,9 +27,9 @@ import { trace } from '../imports';
|
|
|
27
27
|
*/
|
|
28
28
|
export class FcrMonitorControlImpl {
|
|
29
29
|
static {
|
|
30
|
-
[_initProto] = _applyDecs(this, [[
|
|
30
|
+
[_initProto] = _applyDecs(this, [[_uploadEventDecs, 2, "uploadEvent"]], []).e;
|
|
31
31
|
}
|
|
32
|
-
_monitor = void _initProto(this);
|
|
32
|
+
[(_uploadEventDecs = trace(['event']), "_monitor")] = void _initProto(this);
|
|
33
33
|
constructor(engine, _config) {
|
|
34
34
|
this._config = _config;
|
|
35
35
|
this._monitor = engine.getMonitor();
|
|
@@ -23,10 +23,11 @@ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e =
|
|
|
23
23
|
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; }
|
|
24
24
|
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; }
|
|
25
25
|
import { AgoraObservable, md5, Duration, ActionWhenTaskFail, AgoraScheduler, trace } from '../imports';
|
|
26
|
-
import {
|
|
26
|
+
import { generateFcrCoreServerError } from '../utilities/error';
|
|
27
27
|
import { createLogger, generateLogObserver } from '../utilities/logger';
|
|
28
28
|
import { fcrPeerSessionParamsSchema, fcrSessionBaseSchema, stringKeyUnknownValueSchema, stringSchema } from '../schema';
|
|
29
29
|
import validateParams from '../utilities/validate-params';
|
|
30
|
+
import { DetailErrorCode } from '../imports';
|
|
30
31
|
/**
|
|
31
32
|
* @internal
|
|
32
33
|
*/
|
|
@@ -35,7 +36,7 @@ export class FcrPeerSessionControlImpl {
|
|
|
35
36
|
[_initProto] = _applyDecs(this, [[_startPeerSessionDecs, 2, "startPeerSession"], [_stopPeerSessionDecs, 2, "stopPeerSession"], [_acceptPeerSessionDecs, 2, "acceptPeerSession"], [_rejectPeerSessionDecs, 2, "rejectPeerSession"]], []).e;
|
|
36
37
|
}
|
|
37
38
|
//@internal
|
|
38
|
-
[(_startPeerSessionDecs = [trace, validateParams(fcrPeerSessionParamsSchema)], _stopPeerSessionDecs = [trace, validateParams(stringSchema)], _acceptPeerSessionDecs = [trace, validateParams(fcrSessionBaseSchema, stringKeyUnknownValueSchema.optional())], _rejectPeerSessionDecs = [trace, validateParams(fcrSessionBaseSchema, stringKeyUnknownValueSchema.optional())], "logger")] = (_initProto(this), createLogger({
|
|
39
|
+
[(_startPeerSessionDecs = [trace(['params']), validateParams(fcrPeerSessionParamsSchema)], _stopPeerSessionDecs = [trace(['sessionId']), validateParams(stringSchema)], _acceptPeerSessionDecs = [trace(['session', 'cause']), validateParams(fcrSessionBaseSchema, stringKeyUnknownValueSchema.optional())], _rejectPeerSessionDecs = [trace(['session', 'cause']), validateParams(fcrSessionBaseSchema, stringKeyUnknownValueSchema.optional())], "logger")] = (_initProto(this), createLogger({
|
|
39
40
|
prefix: 'FcrPeerSessionControlImpl'
|
|
40
41
|
}));
|
|
41
42
|
//@internal
|
|
@@ -89,18 +90,18 @@ export class FcrPeerSessionControlImpl {
|
|
|
89
90
|
this.logger.info(`[PeerSession] put into session schedule: ${session.sessionId}, next ts: ${nextTs}, remain: ${nextTs - Date.now()}ms`);
|
|
90
91
|
return session.sessionId;
|
|
91
92
|
} catch (e) {
|
|
92
|
-
throw generateFcrCoreServerError(
|
|
93
|
+
throw generateFcrCoreServerError(DetailErrorCode.LOCAL_HTTP_REQUEST_FAILED, 'start peer session failed', e);
|
|
93
94
|
}
|
|
94
95
|
}
|
|
95
96
|
stopPeerSession(sessionId) {
|
|
96
|
-
this._scheduleMap.delete(sessionId);
|
|
97
|
+
return this._scheduleMap.delete(sessionId);
|
|
97
98
|
}
|
|
98
99
|
async acceptPeerSession(session, cause) {
|
|
99
100
|
if (this._isSessionExpired(session)) {
|
|
100
|
-
throw generateFcrCoreServerError(
|
|
101
|
+
throw generateFcrCoreServerError(DetailErrorCode.EXPIRED, 'accept peer session failed: session expired', new Error());
|
|
101
102
|
}
|
|
102
103
|
try {
|
|
103
|
-
this._api.deletePeerSession({
|
|
104
|
+
return this._api.deletePeerSession({
|
|
104
105
|
userId: this._userId,
|
|
105
106
|
sessionId: session.sessionId,
|
|
106
107
|
sessionKey: session.sessionKey,
|
|
@@ -111,15 +112,15 @@ export class FcrPeerSessionControlImpl {
|
|
|
111
112
|
}
|
|
112
113
|
});
|
|
113
114
|
} catch (e) {
|
|
114
|
-
throw generateFcrCoreServerError(
|
|
115
|
+
throw generateFcrCoreServerError(DetailErrorCode.LOCAL_HTTP_REQUEST_FAILED, 'accept peer session failed', e);
|
|
115
116
|
}
|
|
116
117
|
}
|
|
117
118
|
async rejectPeerSession(session, cause) {
|
|
118
119
|
if (this._isSessionExpired(session)) {
|
|
119
|
-
throw generateFcrCoreServerError(
|
|
120
|
+
throw generateFcrCoreServerError(DetailErrorCode.EXPIRED, 'reject peer session failed: session expired', new Error());
|
|
120
121
|
}
|
|
121
122
|
try {
|
|
122
|
-
this._api.deletePeerSession({
|
|
123
|
+
return this._api.deletePeerSession({
|
|
123
124
|
userId: this._userId,
|
|
124
125
|
sessionId: session.sessionId,
|
|
125
126
|
sessionKey: session.sessionKey,
|
|
@@ -130,7 +131,7 @@ export class FcrPeerSessionControlImpl {
|
|
|
130
131
|
}
|
|
131
132
|
});
|
|
132
133
|
} catch (e) {
|
|
133
|
-
throw generateFcrCoreServerError(
|
|
134
|
+
throw generateFcrCoreServerError(DetailErrorCode.LOCAL_HTTP_REQUEST_FAILED, 'reject peer session failed', e);
|
|
134
135
|
}
|
|
135
136
|
}
|
|
136
137
|
addObserver(observer) {
|
|
@@ -155,13 +156,13 @@ export class FcrPeerSessionControlImpl {
|
|
|
155
156
|
interval: 0
|
|
156
157
|
};
|
|
157
158
|
if (this._isSessionExpired(session)) {
|
|
158
|
-
this.logger.info(`
|
|
159
|
+
this.logger.info(`peer session expired, removed: ${session.sessionId}`);
|
|
159
160
|
this._scheduleMap.delete(session.sessionId);
|
|
160
161
|
continue;
|
|
161
162
|
}
|
|
162
163
|
// check timeout
|
|
163
164
|
if (params.nextTs < Date.now()) {
|
|
164
|
-
this.logger.info(`
|
|
165
|
+
this.logger.info(`ping session: ${session.sessionId}`);
|
|
165
166
|
try {
|
|
166
167
|
const {
|
|
167
168
|
data: {
|
|
@@ -184,7 +185,7 @@ export class FcrPeerSessionControlImpl {
|
|
|
184
185
|
this.logger.info(`[PeerSession] refresh session schedule: ${session.sessionId}, next ts: ${nextTs}`);
|
|
185
186
|
}
|
|
186
187
|
} catch (e) {
|
|
187
|
-
this.logger.error(`
|
|
188
|
+
this.logger.error(`ping session failed: ${e}`);
|
|
188
189
|
}
|
|
189
190
|
}
|
|
190
191
|
}
|
|
@@ -193,7 +194,7 @@ export class FcrPeerSessionControlImpl {
|
|
|
193
194
|
const session = this._receivedMap.get(key);
|
|
194
195
|
if (this._isSessionExpired(session)) {
|
|
195
196
|
this._receivedMap.delete(key);
|
|
196
|
-
this.logger.info(`
|
|
197
|
+
this.logger.info(`delete session callback: ${key}`);
|
|
197
198
|
}
|
|
198
199
|
}
|
|
199
200
|
}
|
|
@@ -273,6 +274,6 @@ export class FcrPeerSessionControlImpl {
|
|
|
273
274
|
return session.timestamp + session.duration * Duration.second(1) < Date.now();
|
|
274
275
|
}
|
|
275
276
|
_addLogObserver() {
|
|
276
|
-
this.addObserver(generateLogObserver(this.logger, ['onPeerSessionAccepted', 'onPeerSessionReceived', 'onPeerSessionRejected']));
|
|
277
|
+
this.addObserver(generateLogObserver(this.logger, [['onPeerSessionAccepted', ['session']], ['onPeerSessionReceived', ['session']], ['onPeerSessionRejected', ['session']]]));
|
|
277
278
|
}
|
|
278
279
|
}
|