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
|
@@ -25,12 +25,14 @@ import { AgoraObservable, retryAttempt, to, trace } from '../imports';
|
|
|
25
25
|
import { RoomControlFactory } from '../room-control/room-control-factory';
|
|
26
26
|
import { FcrRoomType } from '../room-control/type';
|
|
27
27
|
import { fcrRoomJoinOptionsSchema, stringSchema } from '../schema';
|
|
28
|
-
import {
|
|
28
|
+
import { FcrReturnCode } from '../type';
|
|
29
|
+
import { generateFcrCoreClientError, handleRequestError } from '../utilities/error';
|
|
29
30
|
import { FcrJoinHelper, handleJoinRetryFailure } from '../utilities/join-helper';
|
|
30
31
|
import { canRetryJoinError } from '../utilities/retry-helpers';
|
|
31
32
|
import { createLogger, generateLogObserver } from '../utilities/logger';
|
|
32
33
|
import validateParams from '../utilities/validate-params';
|
|
33
34
|
import { ROOM_ROUTER_CONSTANTS } from './type';
|
|
35
|
+
import { DetailErrorCode, ErrorModuleCode } from '../imports';
|
|
34
36
|
|
|
35
37
|
/**
|
|
36
38
|
* @internal
|
|
@@ -40,7 +42,7 @@ export class FcrRoomRouterImpl {
|
|
|
40
42
|
static {
|
|
41
43
|
[_initProto] = _applyDecs(this, [[_initDecs, 2, "_init"], [_joinRoomDecs, 2, "joinRoom"], [trace, 2, "leaveRoom"]], []).e;
|
|
42
44
|
}
|
|
43
|
-
[(_initDecs = [trace, validateParams(stringSchema)], _joinRoomDecs = [trace, validateParams(fcrRoomJoinOptionsSchema)], "logger")] = (_initProto(this), createLogger({
|
|
45
|
+
[(_initDecs = [trace(['roomId']), validateParams(stringSchema)], _joinRoomDecs = [trace(['options']), validateParams(fcrRoomJoinOptionsSchema)], "logger")] = (_initProto(this), createLogger({
|
|
44
46
|
prefix: 'FcrRoomRouterImpl'
|
|
45
47
|
}));
|
|
46
48
|
_abortController = null;
|
|
@@ -84,6 +86,7 @@ export class FcrRoomRouterImpl {
|
|
|
84
86
|
isJoined: false
|
|
85
87
|
};
|
|
86
88
|
this._bypass = undefined;
|
|
89
|
+
return FcrReturnCode.SUCCESS;
|
|
87
90
|
}
|
|
88
91
|
async joinRoom(options) {
|
|
89
92
|
this._abortController = new AbortController();
|
|
@@ -104,6 +107,7 @@ export class FcrRoomRouterImpl {
|
|
|
104
107
|
this._abortController = null;
|
|
105
108
|
this._roomControl?.leave();
|
|
106
109
|
this._roomControl = null;
|
|
110
|
+
return FcrReturnCode.SUCCESS;
|
|
107
111
|
}
|
|
108
112
|
|
|
109
113
|
/**
|
|
@@ -112,7 +116,7 @@ export class FcrRoomRouterImpl {
|
|
|
112
116
|
*/
|
|
113
117
|
_validateRoomJoinState() {
|
|
114
118
|
if (this._nextRoomRoute.isJoined) {
|
|
115
|
-
throw generateFcrCoreClientError(
|
|
119
|
+
throw generateFcrCoreClientError(ErrorModuleCode.FCR_ROOM, DetailErrorCode.UNDEFINED_ERROR, 'Room join failed: The user has an active connection to the room.', new Error('Room join failed: The user has an active connection to the room.'));
|
|
116
120
|
}
|
|
117
121
|
}
|
|
118
122
|
|
|
@@ -163,7 +167,7 @@ export class FcrRoomRouterImpl {
|
|
|
163
167
|
const {
|
|
164
168
|
data,
|
|
165
169
|
ts
|
|
166
|
-
} = await handleRequestError(() => this._apiService.checkIn(checkInParams),
|
|
170
|
+
} = await handleRequestError(() => this._apiService.checkIn(checkInParams), ErrorModuleCode.FCR_ENGINE);
|
|
167
171
|
return {
|
|
168
172
|
data,
|
|
169
173
|
ts
|
|
@@ -218,7 +222,7 @@ export class FcrRoomRouterImpl {
|
|
|
218
222
|
*/
|
|
219
223
|
_handleJoinRoomError(error) {
|
|
220
224
|
this.logger.error(`Failed to join the room: ${error.message}`);
|
|
221
|
-
const fcrError =
|
|
225
|
+
const fcrError = generateFcrCoreClientError(ErrorModuleCode.FCR_ROOM, DetailErrorCode.LOCAL_HTTP_REQUEST_FAILED, `join room failed: ${error.message}`);
|
|
222
226
|
this._observable.notifyObservers('onErrorOccurred', fcrError);
|
|
223
227
|
}
|
|
224
228
|
|
|
@@ -248,7 +252,7 @@ export class FcrRoomRouterImpl {
|
|
|
248
252
|
}
|
|
249
253
|
}
|
|
250
254
|
_addLogObserver() {
|
|
251
|
-
this.addObserver(generateLogObserver(this.logger, ['onErrorOccurred', 'onRoomJoined', 'onRoomRouteSwitched']));
|
|
255
|
+
this.addObserver(generateLogObserver(this.logger, [['onErrorOccurred', ['error']], ['onRoomJoined', ['roomControl']], ['onRoomRouteSwitched', ['nextRoomRoute']]]));
|
|
252
256
|
}
|
|
253
257
|
addObserver(observer) {
|
|
254
258
|
this._observable.addObserver(observer);
|
package/lib-es/schema.js
CHANGED
|
@@ -137,8 +137,7 @@ export const AgoraRtcDimensions = z.object({
|
|
|
137
137
|
export const agoraRtcVideoEncoderConfigurationSchema = z.object({
|
|
138
138
|
dimensions: AgoraRtcDimensions,
|
|
139
139
|
frameRate: numberSchema,
|
|
140
|
-
bitrate: numberSchema
|
|
141
|
-
isMirror: booleanSchema
|
|
140
|
+
bitrate: numberSchema
|
|
142
141
|
});
|
|
143
142
|
// Stream Config Schemas
|
|
144
143
|
export const fcrStreamJoinConfig = z.object({
|
package/lib-es/service/api.js
CHANGED
|
@@ -12,7 +12,7 @@ export class FcrCoreServiceApi {
|
|
|
12
12
|
if (pathIncludeRegion) {
|
|
13
13
|
pathPrefix = `/${toLower(region)}${pathPrefix}`;
|
|
14
14
|
}
|
|
15
|
-
this.logger.info('
|
|
15
|
+
this.logger.info('set path prefix for Core Service API:', pathPrefix);
|
|
16
16
|
this._pathPrefix = pathPrefix;
|
|
17
17
|
this._client.setPathPrefix(pathPrefix);
|
|
18
18
|
}
|
|
@@ -423,9 +423,7 @@ export class FcrCoreServiceApi {
|
|
|
423
423
|
const res = await this._client.fetch({
|
|
424
424
|
path: `/v1/rooms/${roomId}/users/${userUuid}/properties`,
|
|
425
425
|
method: 'DELETE',
|
|
426
|
-
data:
|
|
427
|
-
users: data
|
|
428
|
-
}
|
|
426
|
+
data: data
|
|
429
427
|
});
|
|
430
428
|
return res.data;
|
|
431
429
|
}
|
|
@@ -714,16 +712,13 @@ export class FcrCoreServiceApi {
|
|
|
714
712
|
}
|
|
715
713
|
async revokeUserRole({
|
|
716
714
|
roomId,
|
|
717
|
-
remoteRole
|
|
718
|
-
localRole,
|
|
719
|
-
userId
|
|
715
|
+
remoteRole
|
|
720
716
|
}) {
|
|
721
717
|
const res = await this._client.fetch({
|
|
722
|
-
path: `/v1/rooms/${roomId}/
|
|
723
|
-
method: '
|
|
718
|
+
path: `/v1/rooms/${roomId}/claim/host`,
|
|
719
|
+
method: 'POST',
|
|
724
720
|
data: {
|
|
725
|
-
remoteRole
|
|
726
|
-
localRole
|
|
721
|
+
remoteRole
|
|
727
722
|
}
|
|
728
723
|
});
|
|
729
724
|
return res.data;
|
|
@@ -923,12 +918,22 @@ export class FcrCoreServiceApi {
|
|
|
923
918
|
});
|
|
924
919
|
}
|
|
925
920
|
|
|
921
|
+
/**
|
|
922
|
+
* @description 准备 / 取消白板
|
|
923
|
+
*/
|
|
924
|
+
async toggleWhiteboardPreloadState(roomId, state) {
|
|
925
|
+
return this._client.fetch({
|
|
926
|
+
path: `/v1/rooms/${roomId}/widgets/netlessBoard/preload/${state}`,
|
|
927
|
+
method: 'PUT'
|
|
928
|
+
});
|
|
929
|
+
}
|
|
930
|
+
|
|
926
931
|
/**
|
|
927
932
|
* @description 开 / 关白板
|
|
928
933
|
*/
|
|
929
934
|
async toggleWhiteboardActivityState(roomId, state) {
|
|
930
935
|
return this._client.fetch({
|
|
931
|
-
path: `/
|
|
936
|
+
path: `/v2/rooms/${roomId}/widgets/netlessBoard/states/${state}`,
|
|
932
937
|
method: 'PUT'
|
|
933
938
|
});
|
|
934
939
|
}
|
package/lib-es/type.js
CHANGED
|
@@ -7,12 +7,14 @@ import { FcrUserRole } from './room-control/user-control/type';
|
|
|
7
7
|
// 模块类型导出(按功能模块分组)
|
|
8
8
|
// 聊天连接模块
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
import { getRtcPresetParameters } from './utilities/parameters';
|
|
11
11
|
|
|
12
12
|
// 第三方类型别名(统一前缀避免冲突)
|
|
13
|
-
export {
|
|
14
|
-
|
|
13
|
+
export { AgoraRtcAiDenoiseLevel as FcrAiDenoiseLevel, AgoraRtcAudioSourceType as FcrAudioSourceType, AgoraRtcCapability as FcrCapability, AgoraRteConnectionState as FcrConnectionState, AgoraRtcMediaSourceState as FcrMediaSourceState, AgoraRteRegion as FcrRegion, AgoraRteRoomConnectorType as FcrRoomConnectorType, AgoraRteScreenCaptureType as FcrScreenCaptureType, AgoraRteLatencyLevel as FcrStreamLatencyLevel, AgoraRteStreamPrivilegeAudioSourceType as FcrStreamPrivilegeAudioSourceType, AgoraRteStreamPrivilegeOperation as FcrStreamPrivilegeOperation, AgoraRteStreamPrivilegeVideoSourceType as FcrStreamPrivilegeVideoSourceType, AgoraRteMediaStreamType as FcrStreamType, AgoraRteUserUpdatedReason as FcrUserUpdatedReason, AgoraRteVideoOrientation as FcrVideoOrientation, AgoraRtcRenderMode as FcrVideoRenderMode, AgoraRtcVideoSourceType as FcrVideoSourceType, AgoraRtcVideoStreamType as FcrVideoStreamType, registerPlugin } from './imports';
|
|
14
|
+
import { FcrDualVideoStreamConfig } from './utilities/dual-video-stream-config';
|
|
15
|
+
import { FcrVideoEncoderConfig } from './utilities/video-encoder-config';
|
|
15
16
|
// 基础类型别名(简化常用类型引用)
|
|
17
|
+
export { FcrDualVideoStreamConfig };
|
|
16
18
|
|
|
17
19
|
// 媒体控制模块
|
|
18
20
|
|
|
@@ -21,36 +23,28 @@ export { AgoraRteRegion as FcrRegion, AgoraRteMediaStreamType as FcrStreamType,
|
|
|
21
23
|
// 点对点会话模块
|
|
22
24
|
|
|
23
25
|
// 房间控制模块 - 能力控制
|
|
24
|
-
|
|
25
26
|
export { FcrAbility } from './room-control/ability-control/type';
|
|
26
|
-
|
|
27
27
|
// 房间控制模块 - 聊天室控制
|
|
28
|
-
|
|
29
28
|
export { FcrChatRoomConnectionState, FcrChatRoomMessageType } from './room-control/chatroom-control/type';
|
|
30
|
-
|
|
31
29
|
// 房间控制模块 - 翻译控制
|
|
32
|
-
|
|
33
|
-
export { FcrLanguage, FcrInterpreterActionType } from './room-control/interpreter-control/types';
|
|
30
|
+
export { FcrInterpreterActionType, FcrLanguage } from './room-control/interpreter-control/types';
|
|
34
31
|
|
|
35
32
|
// 房间控制模块 - 权限控制
|
|
36
33
|
|
|
37
|
-
export {
|
|
34
|
+
export { FcrChatPermissionType, FcrOperatePermissionType, FcrPermissionAction, FcrPrivilegeUserRole, FcrPrivilegeUserRoleToStringMap, FcrPrivilegeUserStringToRoleMap, FcrSecurityAction, FcrWatermarkPermissionState } from './room-control/privilege-control/type';
|
|
38
35
|
|
|
39
36
|
// 房间控制模块 - 连接器控制
|
|
40
|
-
|
|
41
|
-
export { FcrIPConnectorSessionType, FcrRoomConnectorSessionReason, FcrRoomConnectorSessionState, FcrRoomConnectorPhoneRegion } from './room-control/room-connector-control/type';
|
|
37
|
+
export { FcrIPConnectorSessionType, FcrRoomConnectorPhoneRegion, FcrRoomConnectorSessionReason, FcrRoomConnectorSessionState } from './room-control/room-connector-control/type';
|
|
42
38
|
|
|
43
39
|
// 房间控制模块 - 房间会话
|
|
44
40
|
|
|
45
41
|
// 房间控制模块 - 共享控制
|
|
46
|
-
|
|
47
42
|
export { FcrScreenSharingState, FcrWhiteboardState } from './room-control/sharing-control/type';
|
|
48
43
|
|
|
49
44
|
// 房间控制模块 - 流控制
|
|
50
45
|
|
|
51
46
|
// 房间控制模块 - 用户控制
|
|
52
|
-
|
|
53
|
-
export { FcrUserLeftReason, FcrUserKickedOutType, FcrUserRole } from './room-control/user-control/type';
|
|
47
|
+
export { FcrUserKickedOutType, FcrUserLeftReason, FcrUserRole } from './room-control/user-control/type';
|
|
54
48
|
|
|
55
49
|
// 房间控制模块 - 白板标注控制
|
|
56
50
|
|
|
@@ -60,6 +54,8 @@ export { FcrUserLeftReason, FcrUserKickedOutType, FcrUserRole } from './room-con
|
|
|
60
54
|
|
|
61
55
|
// 服务相关类型
|
|
62
56
|
|
|
57
|
+
export { FcrVideoEncoderConfig };
|
|
58
|
+
|
|
63
59
|
// 核心引擎类型扩展
|
|
64
60
|
|
|
65
61
|
// 房间相关核心类型
|
|
@@ -141,6 +137,11 @@ export const FcrUserStringToRoleMap = {
|
|
|
141
137
|
observer: FcrUserRole.OBSERVER,
|
|
142
138
|
robot: FcrUserRole.ROBOT
|
|
143
139
|
};
|
|
140
|
+
export let FcrReturnCode = /*#__PURE__*/function (FcrReturnCode) {
|
|
141
|
+
FcrReturnCode[FcrReturnCode["UNDEFINED"] = -1] = "UNDEFINED";
|
|
142
|
+
FcrReturnCode[FcrReturnCode["SUCCESS"] = 0] = "SUCCESS";
|
|
143
|
+
return FcrReturnCode;
|
|
144
|
+
}({});
|
|
144
145
|
|
|
145
146
|
// 直播相关类型
|
|
146
147
|
export let FcrLiveStreamingLayoutType = /*#__PURE__*/function (FcrLiveStreamingLayoutType) {
|
|
@@ -159,12 +160,63 @@ export let RoomMessageKey = /*#__PURE__*/function (RoomMessageKey) {
|
|
|
159
160
|
RoomMessageKey["USER_WAITING_ROOM_JOINED"] = "USER_WAITING_ROOM_JOINED";
|
|
160
161
|
return RoomMessageKey;
|
|
161
162
|
}({});
|
|
162
|
-
export { FcrLineType } from './room-control/type';
|
|
163
163
|
export { FcrDeviceType } from './media-control/type';
|
|
164
|
+
export { FcrLineType } from './room-control/type';
|
|
165
|
+
export { FcrError } from './utilities/error';
|
|
164
166
|
export let FcrStreamState = /*#__PURE__*/function (FcrStreamState) {
|
|
165
167
|
FcrStreamState[FcrStreamState["UNPUBLISH"] = 0] = "UNPUBLISH";
|
|
166
168
|
FcrStreamState[FcrStreamState["PUBLISH"] = 1] = "PUBLISH";
|
|
167
169
|
return FcrStreamState;
|
|
168
170
|
}({});
|
|
169
|
-
export {
|
|
170
|
-
|
|
171
|
+
export { FcrBoardShape, FcrBoardToolType } from './room-control/whiteboard-control-v2/enum';
|
|
172
|
+
/** 引擎配置类 */
|
|
173
|
+
export class FcrCoreEngineConfig {
|
|
174
|
+
/** 应用唯一标识 */
|
|
175
|
+
|
|
176
|
+
/** 身份验证令牌 */
|
|
177
|
+
|
|
178
|
+
/** 用户唯一标识 */
|
|
179
|
+
|
|
180
|
+
/** 服务区域 */
|
|
181
|
+
|
|
182
|
+
/** 双摄像头视频流配置 */
|
|
183
|
+
|
|
184
|
+
/** 双屏幕视频流配置 */
|
|
185
|
+
|
|
186
|
+
/** 额外参数配置 */
|
|
187
|
+
|
|
188
|
+
constructor(params) {
|
|
189
|
+
this.appId = params.appId;
|
|
190
|
+
this.token = params.token;
|
|
191
|
+
this.userId = params.userId;
|
|
192
|
+
this.region = params.region;
|
|
193
|
+
this.dualCameraVideoStreamConfig = params.dualCameraVideoStreamConfig;
|
|
194
|
+
this.dualScreenVideoStreamConfig = params.dualScreenVideoStreamConfig;
|
|
195
|
+
this.parameters = params.parameters;
|
|
196
|
+
this._prependInternalParameters();
|
|
197
|
+
}
|
|
198
|
+
static createDefaultConfig(appId, token, region, userId, parameters) {
|
|
199
|
+
return new FcrCoreEngineConfig({
|
|
200
|
+
appId,
|
|
201
|
+
token,
|
|
202
|
+
userId,
|
|
203
|
+
region,
|
|
204
|
+
dualCameraVideoStreamConfig: FcrDualVideoStreamConfig.createDefaultCameraConfig(),
|
|
205
|
+
dualScreenVideoStreamConfig: FcrDualVideoStreamConfig.createDefaultScreenConfig(),
|
|
206
|
+
parameters
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
_prependInternalParameters() {
|
|
210
|
+
const rtcPresetParameters = getRtcPresetParameters();
|
|
211
|
+
if (!this.parameters) {
|
|
212
|
+
this.parameters = {
|
|
213
|
+
rtc: rtcPresetParameters
|
|
214
|
+
};
|
|
215
|
+
} else if (!this.parameters.rtc) {
|
|
216
|
+
this.parameters.rtc = rtcPresetParameters;
|
|
217
|
+
} else {
|
|
218
|
+
// 将内部参数插入到数组前列
|
|
219
|
+
this.parameters.rtc.unshift(...rtcPresetParameters);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import "core-js/modules/web.dom-exception.stack.js";
|
|
2
|
+
import { retryAttempt, to } from '../imports';
|
|
3
|
+
/**
|
|
4
|
+
* Creates an abortable retry operation that can be cancelled at any time.
|
|
5
|
+
*
|
|
6
|
+
* The handler function will be retried up to `retriesMax` times if it fails.
|
|
7
|
+
* The operation can be cancelled by calling the returned abort function,
|
|
8
|
+
* which will cause the promise to reject with an AbortError.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* const [abort, promise] = abortableRetry(async (signal) => {
|
|
13
|
+
* await asyncFunction1();
|
|
14
|
+
* // Check if aborted after each async operation
|
|
15
|
+
* signal.throwIfAborted();
|
|
16
|
+
*
|
|
17
|
+
* await asyncFunction2();
|
|
18
|
+
* signal.throwIfAborted();
|
|
19
|
+
*
|
|
20
|
+
* return result;
|
|
21
|
+
* }, { retriesMax: 10 });
|
|
22
|
+
*
|
|
23
|
+
* // Cancel the operation at any time
|
|
24
|
+
* setTimeout(() => abort(), 5000);
|
|
25
|
+
*
|
|
26
|
+
* const [err, result] = await promise;
|
|
27
|
+
* if (err?.name === 'AbortError') {
|
|
28
|
+
* console.log('Operation was cancelled');
|
|
29
|
+
* }
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* @param handler - Async function that receives an AbortSignal.
|
|
33
|
+
* Should call `signal.throwIfAborted()` periodically to check for cancellation.
|
|
34
|
+
* @param options - Retry configuration
|
|
35
|
+
* @returns Tuple of [abort function, result promise]. The promise resolves to [error, result].
|
|
36
|
+
*/
|
|
37
|
+
export const abortableRetry = (handler, options) => {
|
|
38
|
+
const abortController = new AbortController();
|
|
39
|
+
const promise = to(retryAttempt(async () => {
|
|
40
|
+
abortController.signal.throwIfAborted();
|
|
41
|
+
const result = await handler(abortController.signal);
|
|
42
|
+
abortController.signal.throwIfAborted();
|
|
43
|
+
return result;
|
|
44
|
+
}, [], {
|
|
45
|
+
retriesMax: options.retriesMax
|
|
46
|
+
}).fail(async options => {
|
|
47
|
+
if (abortController.signal.aborted) {
|
|
48
|
+
throw new DOMException('Operation aborted', 'AbortError');
|
|
49
|
+
}
|
|
50
|
+
await options.timeFn();
|
|
51
|
+
return true;
|
|
52
|
+
}).exec());
|
|
53
|
+
return [() => abortController.abort(), promise];
|
|
54
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { FcrVideoEncoderConfig } from './video-encoder-config';
|
|
2
|
+
export let FcrDualVideoStreamConfig;
|
|
3
|
+
(function (_FcrDualVideoStreamConfig) {
|
|
4
|
+
function createDefaultCameraConfig() {
|
|
5
|
+
return {
|
|
6
|
+
highVideoEncoderConfig: FcrVideoEncoderConfig.createDefaultHighCameraConfig(),
|
|
7
|
+
lowVideoEncoderConfig: FcrVideoEncoderConfig.createDefaultLowCameraConfig(),
|
|
8
|
+
enableDualStreamMode: true
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
_FcrDualVideoStreamConfig.createDefaultCameraConfig = createDefaultCameraConfig;
|
|
12
|
+
function createDefaultScreenConfig() {
|
|
13
|
+
return {
|
|
14
|
+
highVideoEncoderConfig: FcrVideoEncoderConfig.createDefaultClarityScreenConfig(),
|
|
15
|
+
enableDualStreamMode: false
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
_FcrDualVideoStreamConfig.createDefaultScreenConfig = createDefaultScreenConfig;
|
|
19
|
+
})(FcrDualVideoStreamConfig || (FcrDualVideoStreamConfig = {}));
|
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
* 提供统一的错误创建和处理机制,支持实例化配置
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { DetailErrorCode, ErrorModuleCode } from '../imports';
|
|
8
|
+
import { generateFcrCoreClientError } from './error';
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* 控制器类型枚举
|
|
@@ -35,7 +36,7 @@ export let ControllerType = /*#__PURE__*/function (ControllerType) {
|
|
|
35
36
|
export class FcrErrorHelper {
|
|
36
37
|
constructor(config = {}) {
|
|
37
38
|
this.config = {
|
|
38
|
-
defaultModuleCode:
|
|
39
|
+
defaultModuleCode: ErrorModuleCode.FCR_ROOM,
|
|
39
40
|
enableDetailedMessages: true,
|
|
40
41
|
logPrefix: 'FCR',
|
|
41
42
|
autoLog: false,
|
|
@@ -51,7 +52,7 @@ export class FcrErrorHelper {
|
|
|
51
52
|
createControllerNotInitializedError(controllerType, moduleCode) {
|
|
52
53
|
const module = moduleCode ?? this.config.defaultModuleCode;
|
|
53
54
|
const message = this.config.enableDetailedMessages ? `[${this.config.logPrefix}] The ${controllerType} controller is not initialized, please join the room first` : `${controllerType} controller not initialized`;
|
|
54
|
-
const error =
|
|
55
|
+
const error = generateFcrCoreClientError(module, DetailErrorCode.NOT_JOINED_ROOM, message);
|
|
55
56
|
if (this.config.autoLog) {
|
|
56
57
|
console.error(`${this.config.logPrefix}: ${message}`);
|
|
57
58
|
}
|
|
@@ -68,7 +69,7 @@ export class FcrErrorHelper {
|
|
|
68
69
|
createOperationConflictError(operation, reason, moduleCode) {
|
|
69
70
|
const module = moduleCode ?? this.config.defaultModuleCode;
|
|
70
71
|
const message = this.config.enableDetailedMessages ? `[${this.config.logPrefix}] Failed to ${operation}: ${reason}` : `${operation} failed: ${reason}`;
|
|
71
|
-
const error =
|
|
72
|
+
const error = generateFcrCoreClientError(module, DetailErrorCode.JOIN_CONFLICT, message);
|
|
72
73
|
if (this.config.autoLog) {
|
|
73
74
|
console.error(`${this.config.logPrefix}: ${message}`);
|
|
74
75
|
}
|
|
@@ -84,7 +85,7 @@ export class FcrErrorHelper {
|
|
|
84
85
|
createOperationCanceledError(operation, moduleCode) {
|
|
85
86
|
const module = moduleCode ?? this.config.defaultModuleCode;
|
|
86
87
|
const message = this.config.enableDetailedMessages ? `[${this.config.logPrefix}] ${operation} operation has been cancelled` : `${operation} cancelled`;
|
|
87
|
-
const error =
|
|
88
|
+
const error = generateFcrCoreClientError(module, DetailErrorCode.NOT_JOINED_ROOM, message);
|
|
88
89
|
if (this.config.autoLog) {
|
|
89
90
|
console.error(`${this.config.logPrefix}: ${message}`);
|
|
90
91
|
}
|
|
@@ -100,7 +101,7 @@ export class FcrErrorHelper {
|
|
|
100
101
|
createSendMessageError(originalError, moduleCode) {
|
|
101
102
|
const module = moduleCode ?? this.config.defaultModuleCode;
|
|
102
103
|
const message = this.config.enableDetailedMessages ? `[${this.config.logPrefix}] Send message failed: ${originalError.message}` : 'send message failed';
|
|
103
|
-
const error =
|
|
104
|
+
const error = generateFcrCoreClientError(module, DetailErrorCode.UNDEFINED_ERROR, message);
|
|
104
105
|
if (this.config.autoLog) {
|
|
105
106
|
console.error(`${this.config.logPrefix}: ${message}`, originalError);
|
|
106
107
|
}
|
|
@@ -117,7 +118,7 @@ export class FcrErrorHelper {
|
|
|
117
118
|
createOperationError(operation, originalError, moduleCode) {
|
|
118
119
|
const module = moduleCode ?? this.config.defaultModuleCode;
|
|
119
120
|
const message = this.config.enableDetailedMessages ? `[${this.config.logPrefix}] ${operation} failed${originalError ? `: ${originalError.message}` : ''}` : `${operation} failed`;
|
|
120
|
-
const error =
|
|
121
|
+
const error = generateFcrCoreClientError(module, DetailErrorCode.NOT_JOINED_ROOM, message);
|
|
121
122
|
if (this.config.autoLog) {
|
|
122
123
|
console.error(`${this.config.logPrefix}: ${message}`, originalError);
|
|
123
124
|
}
|
|
@@ -133,7 +134,7 @@ export class FcrErrorHelper {
|
|
|
133
134
|
createNetworkError(message, moduleCode) {
|
|
134
135
|
const module = moduleCode ?? this.config.defaultModuleCode;
|
|
135
136
|
const formattedMessage = this.config.enableDetailedMessages ? `[${this.config.logPrefix}] Network error: ${message}` : message;
|
|
136
|
-
const error =
|
|
137
|
+
const error = generateFcrCoreClientError(module, DetailErrorCode.LOCAL_HTTP_REQUEST_FAILED, formattedMessage);
|
|
137
138
|
if (this.config.autoLog) {
|
|
138
139
|
console.error(`${this.config.logPrefix}: ${formattedMessage}`);
|
|
139
140
|
}
|
|
@@ -150,7 +151,7 @@ export class FcrErrorHelper {
|
|
|
150
151
|
createInvalidParamsError(paramName, reason, moduleCode) {
|
|
151
152
|
const module = moduleCode ?? this.config.defaultModuleCode;
|
|
152
153
|
const message = this.config.enableDetailedMessages ? `[${this.config.logPrefix}] Invalid parameter '${paramName}': ${reason}` : `Invalid parameter '${paramName}': ${reason}`;
|
|
153
|
-
const error =
|
|
154
|
+
const error = generateFcrCoreClientError(module, DetailErrorCode.INVALID_PARAMS, message);
|
|
154
155
|
if (this.config.autoLog) {
|
|
155
156
|
console.error(`${this.config.logPrefix}: ${message}`);
|
|
156
157
|
}
|
|
@@ -177,7 +178,7 @@ export class FcrErrorHelper {
|
|
|
177
178
|
*/
|
|
178
179
|
static forRoomControl() {
|
|
179
180
|
return new FcrErrorHelper({
|
|
180
|
-
defaultModuleCode:
|
|
181
|
+
defaultModuleCode: ErrorModuleCode.FCR_ROOM,
|
|
181
182
|
logPrefix: 'RoomControl',
|
|
182
183
|
enableDetailedMessages: true
|
|
183
184
|
});
|
|
@@ -188,7 +189,7 @@ export class FcrErrorHelper {
|
|
|
188
189
|
*/
|
|
189
190
|
static forEngine() {
|
|
190
191
|
return new FcrErrorHelper({
|
|
191
|
-
defaultModuleCode:
|
|
192
|
+
defaultModuleCode: ErrorModuleCode.FCR_ENGINE,
|
|
192
193
|
logPrefix: 'Engine',
|
|
193
194
|
enableDetailedMessages: true
|
|
194
195
|
});
|
|
@@ -199,7 +200,7 @@ export class FcrErrorHelper {
|
|
|
199
200
|
*/
|
|
200
201
|
static forLiveStreaming() {
|
|
201
202
|
return new FcrErrorHelper({
|
|
202
|
-
defaultModuleCode:
|
|
203
|
+
defaultModuleCode: ErrorModuleCode.FCR_ROOM_LIVE_STREAMING,
|
|
203
204
|
logPrefix: 'LiveStreaming',
|
|
204
205
|
enableDetailedMessages: true
|
|
205
206
|
});
|
|
@@ -1,60 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DetailErrorCode, ErrorServiceType } from '../imports';
|
|
2
|
+
import { padStart, AgoraRestfulClientError, FcrError } from '../imports';
|
|
2
3
|
export { FcrError } from '../imports';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
return FcrErrorCodeType;
|
|
7
|
-
}({});
|
|
8
|
-
export let FcrErrorModuleCode = /*#__PURE__*/function (FcrErrorModuleCode) {
|
|
9
|
-
FcrErrorModuleCode[FcrErrorModuleCode["ENGINE"] = 10] = "ENGINE";
|
|
10
|
-
FcrErrorModuleCode[FcrErrorModuleCode["ENGINE_PEER_SESSION"] = 11] = "ENGINE_PEER_SESSION";
|
|
11
|
-
FcrErrorModuleCode[FcrErrorModuleCode["ROOM"] = 20] = "ROOM";
|
|
12
|
-
FcrErrorModuleCode[FcrErrorModuleCode["ROOM_USER"] = 21] = "ROOM_USER";
|
|
13
|
-
FcrErrorModuleCode[FcrErrorModuleCode["ROOM_STREAM"] = 22] = "ROOM_STREAM";
|
|
14
|
-
FcrErrorModuleCode[FcrErrorModuleCode["ROOM_GROUP"] = 23] = "ROOM_GROUP";
|
|
15
|
-
FcrErrorModuleCode[FcrErrorModuleCode["ROOM_CHATROOM"] = 24] = "ROOM_CHATROOM";
|
|
16
|
-
FcrErrorModuleCode[FcrErrorModuleCode["ROOM_SESSION"] = 25] = "ROOM_SESSION";
|
|
17
|
-
FcrErrorModuleCode[FcrErrorModuleCode["ROOM_PRIVILEGE"] = 26] = "ROOM_PRIVILEGE";
|
|
18
|
-
FcrErrorModuleCode[FcrErrorModuleCode["ROOM_WHITEBOARD"] = 27] = "ROOM_WHITEBOARD";
|
|
19
|
-
FcrErrorModuleCode[FcrErrorModuleCode["ROOM_CONNECTOR"] = 28] = "ROOM_CONNECTOR";
|
|
20
|
-
FcrErrorModuleCode[FcrErrorModuleCode["ROOM_INTERPRETER"] = 29] = "ROOM_INTERPRETER";
|
|
21
|
-
FcrErrorModuleCode[FcrErrorModuleCode["MEDIA_CONTROL"] = 30] = "MEDIA_CONTROL";
|
|
22
|
-
FcrErrorModuleCode[FcrErrorModuleCode["MEDIA_CONTROL_CAMERA"] = 31] = "MEDIA_CONTROL_CAMERA";
|
|
23
|
-
FcrErrorModuleCode[FcrErrorModuleCode["MEDIA_CONTROL_MICROPHONE"] = 32] = "MEDIA_CONTROL_MICROPHONE";
|
|
24
|
-
FcrErrorModuleCode[FcrErrorModuleCode["MEDIA_CONTROL_LOOPBACK"] = 33] = "MEDIA_CONTROL_LOOPBACK";
|
|
25
|
-
FcrErrorModuleCode[FcrErrorModuleCode["MEDIA_CONTROL_SCREEN"] = 34] = "MEDIA_CONTROL_SCREEN";
|
|
26
|
-
FcrErrorModuleCode[FcrErrorModuleCode["ROOM_STT"] = 35] = "ROOM_STT";
|
|
27
|
-
FcrErrorModuleCode[FcrErrorModuleCode["MONITOR"] = 40] = "MONITOR";
|
|
28
|
-
FcrErrorModuleCode[FcrErrorModuleCode["ROOM_LIVE_STREAMING"] = 41] = "ROOM_LIVE_STREAMING";
|
|
29
|
-
return FcrErrorModuleCode;
|
|
30
|
-
}({});
|
|
31
|
-
export let FcrErrorCode = /*#__PURE__*/function (FcrErrorCode) {
|
|
32
|
-
FcrErrorCode[FcrErrorCode["UNDEFINED_ERROR"] = 1] = "UNDEFINED_ERROR";
|
|
33
|
-
FcrErrorCode[FcrErrorCode["INVALID_PARAMS"] = 10] = "INVALID_PARAMS";
|
|
34
|
-
FcrErrorCode[FcrErrorCode["JSON_PARSE_ERROR"] = 11] = "JSON_PARSE_ERROR";
|
|
35
|
-
FcrErrorCode[FcrErrorCode["LOCAL_HTTP_REQUEST_FAILED"] = 12] = "LOCAL_HTTP_REQUEST_FAILED";
|
|
36
|
-
FcrErrorCode[FcrErrorCode["NOT_LOGGED_IN"] = 13] = "NOT_LOGGED_IN";
|
|
37
|
-
FcrErrorCode[FcrErrorCode["NOT_JOINED_ROOM"] = 14] = "NOT_JOINED_ROOM";
|
|
38
|
-
FcrErrorCode[FcrErrorCode["JOIN_CONFLICT"] = 15] = "JOIN_CONFLICT";
|
|
39
|
-
FcrErrorCode[FcrErrorCode["EXPIRED"] = 15] = "EXPIRED";
|
|
40
|
-
return FcrErrorCode;
|
|
41
|
-
}({});
|
|
4
|
+
|
|
5
|
+
// Export aliases for compatibility
|
|
6
|
+
export { DetailErrorCode as FcrErrorCode, ErrorModuleCode as FcrErrorModuleCode } from '../imports';
|
|
42
7
|
|
|
43
8
|
// helpers
|
|
44
9
|
export const generateFcrCoreClientError = (module, code, message, origin) => {
|
|
45
|
-
|
|
46
|
-
const moduleCode = padStart(String(module), 3, '0'); // 如:'020'
|
|
47
|
-
const errorCode = padStart(String(code), 3, '0'); // 如:'001'
|
|
48
|
-
const fullErrorCode = Number(`${errorType}${moduleCode}${errorCode}`); // 如:'100020001'
|
|
49
|
-
|
|
50
|
-
const errorMessage = `domain: RTE-CLIENT, info: ${message}`;
|
|
51
|
-
return new FcrError({
|
|
52
|
-
code: fullErrorCode,
|
|
53
|
-
message: errorMessage
|
|
54
|
-
});
|
|
10
|
+
return FcrError.create(ErrorServiceType.FCR_CLIENT, module, code, message, origin);
|
|
55
11
|
};
|
|
56
12
|
export const generateFcrCoreServerError = (code, message, origin) => {
|
|
57
|
-
const errorCode = Number(`${
|
|
13
|
+
const errorCode = Number(`${ErrorServiceType.FCR_SERVER}${padStart(String(code), 8, '0')}`);
|
|
58
14
|
const error = new FcrError({
|
|
59
15
|
message: message,
|
|
60
16
|
code: errorCode
|
|
@@ -71,7 +27,7 @@ export const handleRequestError = async (action, errorModuleCode, errorMessage)
|
|
|
71
27
|
throw generateFcrCoreServerError(e.serviceCode ?? -1, e.message, e);
|
|
72
28
|
}
|
|
73
29
|
const error = e;
|
|
74
|
-
throw generateFcrCoreClientError(errorModuleCode,
|
|
30
|
+
throw generateFcrCoreClientError(errorModuleCode, DetailErrorCode.UNDEFINED_ERROR, errorMessage ?? error.message, error);
|
|
75
31
|
}
|
|
76
32
|
};
|
|
77
33
|
|
|
@@ -84,26 +40,4 @@ export const handleRequestError = async (action, errorModuleCode, errorMessage)
|
|
|
84
40
|
// 400000010 // 加入web rtc频道超时了(rtc私有化)
|
|
85
41
|
// 730403100 // 被永久踢出房间
|
|
86
42
|
// error codes that cannot be retried when joining a room
|
|
87
|
-
export const ERROR_CODES_NOT_RETRYABLE_WHEN_JOINING_ROOM = [720410100, 720404100, 732403100, 732403101, 100050051, 300000010, 400000010, 730403100];
|
|
88
|
-
|
|
89
|
-
// New
|
|
90
|
-
export const generateFcrCoreClientErrorNew = (module, code, message) => {
|
|
91
|
-
const errorType = padEnd(String(FcrErrorCodeType.CLIENT), 3, '0'); // 如:'100'
|
|
92
|
-
const moduleCode = padStart(String(module), 3, '0'); // 如:'020'
|
|
93
|
-
const errorCode = padStart(String(code), 3, '0'); // 如:'001'
|
|
94
|
-
const fullErrorCode = Number(`${errorType}${moduleCode}${errorCode}`); // 如:'100020001'
|
|
95
|
-
|
|
96
|
-
const errorMessage = `domain: RTE-CLIENT, info: ${message}`;
|
|
97
|
-
return new FcrError({
|
|
98
|
-
code: fullErrorCode,
|
|
99
|
-
message: errorMessage
|
|
100
|
-
});
|
|
101
|
-
};
|
|
102
|
-
export const generateFcrCoreServerErrorNew = (code, message) => {
|
|
103
|
-
const errorCode = Number(`${FcrErrorCodeType.SERVER}${padStart(String(code), 8, '0')}`);
|
|
104
|
-
const error = new FcrError({
|
|
105
|
-
message: message,
|
|
106
|
-
code: errorCode
|
|
107
|
-
});
|
|
108
|
-
return error;
|
|
109
|
-
};
|
|
43
|
+
export const ERROR_CODES_NOT_RETRYABLE_WHEN_JOINING_ROOM = [720410100, 720404100, 732403100, 732403101, 100050051, 300000010, 400000010, 730403100];
|
|
@@ -9,7 +9,8 @@ import "core-js/modules/esnext.iterator.map.js";
|
|
|
9
9
|
import { convertStreamTypeToPublishState, getPlatform, getVersion, retryAttempt } from '../imports';
|
|
10
10
|
import { FcrUserRoleToStringMap, FcrStreamLatencyLevel } from '../type';
|
|
11
11
|
import { canRetryJoinError } from './retry-helpers';
|
|
12
|
-
import {
|
|
12
|
+
import { handleRequestError } from './error';
|
|
13
|
+
import { ErrorModuleCode } from '../imports';
|
|
13
14
|
import { ROOM_CONTROL_CONSTANTS } from '../room-control/helpers/constants';
|
|
14
15
|
|
|
15
16
|
/**
|
|
@@ -115,7 +116,7 @@ export class FcrJoinHelper {
|
|
|
115
116
|
const checkInParams = this._buildCheckInParams(options, extraParams);
|
|
116
117
|
const apiCall = useInternalApi ? () => this._api.checkInInternal(checkInParams) : () => this._api.checkIn(checkInParams);
|
|
117
118
|
const errorMessage = useInternalApi ? 'check in internal failed' : 'check in failed';
|
|
118
|
-
const res = await handleRequestError(apiCall,
|
|
119
|
+
const res = await handleRequestError(apiCall, ErrorModuleCode.FCR_ROOM, errorMessage);
|
|
119
120
|
return res;
|
|
120
121
|
}
|
|
121
122
|
|
|
@@ -168,7 +169,7 @@ export class FcrJoinHelper {
|
|
|
168
169
|
* @private
|
|
169
170
|
*/
|
|
170
171
|
async _joinScene(streamLatency, streamEncryptionConfig, snapshot, timestamp, onJoinAborted) {
|
|
171
|
-
await this._scene.
|
|
172
|
+
await this._scene.joinWithSnapshot({
|
|
172
173
|
streamLatency: streamLatency,
|
|
173
174
|
streamEncryptionConfig,
|
|
174
175
|
snapshot,
|
|
@@ -1,23 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
};
|
|
9
|
-
export const createLogger = opts => {
|
|
10
|
-
return _createLogger({
|
|
11
|
-
label: 'fcr-core',
|
|
12
|
-
prefix: `${opts.prefix}@${randomString(5)}`
|
|
13
|
-
});
|
|
14
|
-
};
|
|
15
|
-
export const generateLogObserver = (logger, callbackMethods) => {
|
|
16
|
-
const observer = {};
|
|
17
|
-
callbackMethods.forEach(method => {
|
|
18
|
-
observer[method] = (...args) => {
|
|
19
|
-
logger.info(`[API Callback] ${method} [parameters: ${serializeArgs(args)}]`);
|
|
20
|
-
};
|
|
21
|
-
});
|
|
22
|
-
return observer;
|
|
23
|
-
};
|
|
1
|
+
import { LoggerManager } from '../imports';
|
|
2
|
+
const loggerManager = new LoggerManager({
|
|
3
|
+
label: 'fcr-core'
|
|
4
|
+
});
|
|
5
|
+
export const getLogger = loggerManager.getLogger.bind(loggerManager);
|
|
6
|
+
export const createLogger = loggerManager.createLogger.bind(loggerManager);
|
|
7
|
+
export const generateLogObserver = loggerManager.generateLogObserver.bind(loggerManager);
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import packageInfo from '../../package.json';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export const getDependenciesInfo =
|
|
6
|
-
return packageInfo.dependencies[packageName];
|
|
7
|
-
};
|
|
2
|
+
import { PackageInfo } from 'agora-foundation/lib/utilities/package-info';
|
|
3
|
+
const packageInfoObj = new PackageInfo(packageInfo);
|
|
4
|
+
export const getVersion = packageInfoObj.getVersion.bind(packageInfoObj);
|
|
5
|
+
export const getDependenciesInfo = packageInfoObj.getDependenciesInfo.bind(packageInfoObj);
|