yjz-web-sdk 1.0.8-beta.1 → 1.0.8-beta.4

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.
@@ -5,13 +5,23 @@ import { WebRTCConfig } from "./rtc/WebRTCConfig.ts";
5
5
  import type { WebRTCConfigOptions } from './rtc/WebRTCConfig';
6
6
  import { ChannelDataType } from "./data/WebrtcDataType.ts";
7
7
  export declare class WebRTCSdk extends EventEmitter {
8
- config: WebRTCConfig;
9
- signalingClient: SignalingClient;
10
- webRTCClient: WebRTCClient;
8
+ config: WebRTCConfig | null;
9
+ signalingClient: SignalingClient | null;
10
+ webRTCClient: WebRTCClient | null;
11
+ options: WebRTCConfigOptions;
12
+ isConnected: boolean;
13
+ isConnecting: boolean;
14
+ private connectCount;
15
+ private MAX_COUNT;
11
16
  constructor(options: WebRTCConfigOptions);
17
+ initConfig(): Promise<void>;
12
18
  /** 开始连接 signal 服务 */
13
19
  startConnection(): void;
20
+ private prepareConnection;
21
+ reconnect(): Promise<void>;
22
+ initConnectConfig(): void;
14
23
  switchControl(isControl: boolean): void;
24
+ resetConfig(): void;
15
25
  /** 停止连接,并发送退出信令 */
16
26
  stop(): void;
17
27
  /** 开始推流:触发媒体采集与轨道添加 */
@@ -14,3 +14,8 @@ export type TurnTestSummary = {
14
14
  best?: PublicTurnTestResult;
15
15
  all: PublicTurnTestResult[];
16
16
  };
17
+ export interface TurnSelectionResult {
18
+ url?: string;
19
+ rtt?: number;
20
+ error?: string;
21
+ }
@@ -14,7 +14,9 @@ export declare enum FailCode {
14
14
  DATACHANNEL_ERR = 10013,
15
15
  STREAM_STATE = 10014,
16
16
  AUTH_FAILED = 10015,
17
- KICK_OUT_ERR = 10016
17
+ KICK_OUT_ERR = 10016,
18
+ STATE_ERR = 10017,
19
+ OPTION_ERR = 10018
18
20
  }
19
21
  export declare const FailInfoMap: Record<FailCode, {
20
22
  type: string;
@@ -39,5 +41,6 @@ export declare enum EmitType {
39
41
  statisticInfo = "statisticInfo",
40
42
  cloudClipData = "cloudClipData",
41
43
  screenshot = "screenshot",
42
- groupError = "groupError"
44
+ groupError = "groupError",
45
+ reconnect = "reconnect"
43
46
  }
@@ -120,7 +120,8 @@ export declare class ClarityData {
120
120
  export declare class ChannelData {
121
121
  type: ChannelDataType;
122
122
  data: string | null;
123
- constructor(type: ChannelDataType, data?: string | null);
123
+ myId: string | null;
124
+ constructor(type: ChannelDataType, data?: string | null, myId?: string | null);
124
125
  toString(): string;
125
126
  /**
126
127
  * 格式化数据
@@ -144,7 +145,7 @@ export declare class ChannelData {
144
145
  * 生成输入数据
145
146
  * @param data 输入数据对象
146
147
  */
147
- static input(data: any): ChannelData;
148
+ static input(data: any, myId: string): ChannelData;
148
149
  /**
149
150
  * 生成鼠标滚动数据
150
151
  * @param data 输入数据对象
@@ -6,7 +6,7 @@ export interface WebRTCConfigOptions {
6
6
  stunServerUri?: string;
7
7
  stunServerUriAli?: string;
8
8
  stunServerUriTel?: string;
9
- turnServerUri: string;
9
+ turnServerUri?: string;
10
10
  turnServerUserName?: string;
11
11
  turnServerPassword?: string;
12
12
  isControl: boolean;
@@ -20,6 +20,10 @@ export interface WebRTCConfigOptions {
20
20
  token: string;
21
21
  isGroup: boolean;
22
22
  turnKey?: Array<string>;
23
+ hostTurn?: Array<string>;
24
+ spareTurn?: Array<string>;
25
+ maxRecount?: number;
26
+ isCalculate?: boolean;
23
27
  }
24
28
  export declare class WebRTCConfig {
25
29
  signalServerUrl: string;
@@ -3,6 +3,7 @@ import type { WebRTCConfig } from "../rtc/WebRTCConfig.ts";
3
3
  export declare class SignalingClient extends EventEmitter {
4
4
  private config;
5
5
  private webSocket;
6
+ private timeout;
6
7
  constructor(config: WebRTCConfig);
7
8
  /**
8
9
  * 启动 WebSocket 连接,并注册各事件处理
@@ -1,3 +1,6 @@
1
- import type { TurnServerConfig, TurnTestResult, TurnTestSummary } from "../data/TurnType.ts";
1
+ import type { TurnSelectionResult, TurnServerConfig, TurnTestResult, TurnTestSummary } from "../data/TurnType.ts";
2
+ import type { WebRTCConfigOptions } from "../rtc/WebRTCConfig.ts";
2
3
  export declare const testTurnServer: (turnConfig: TurnServerConfig, timeoutMs?: number) => Promise<TurnTestResult>;
3
4
  export declare const testMultipleTurnServers: (servers: string[], timeoutMs?: number) => Promise<TurnTestSummary>;
5
+ export declare const areTurnListsEmpty: (options: WebRTCConfigOptions) => boolean;
6
+ export declare const selectBestTurnServer: (turnList: string[]) => Promise<TurnSelectionResult>;