@vkontakte/calls-sdk 2.8.11-beta.3 → 2.8.11-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.
@@ -0,0 +1,3 @@
1
+ import ConversationResponse from '../types/ConversationResponse';
2
+ export type ConversationResponseSource = 'startConversation' | 'joinConversation' | 'joinConversationByLink' | 'fastStart' | 'fastJoin';
3
+ export declare function assertValidConversationResponse(response: ConversationResponse | null | undefined, source: ConversationResponseSource): void;
@@ -4,6 +4,7 @@ import { StatAggregator } from './StatAggregator';
4
4
  declare enum ECallType {
5
5
  DirectOutgoing = "direct_outgoing",
6
6
  DirectIncoming = "direct_incoming",
7
+ DirectJoin = "direct_join",
7
8
  ServerIncoming = "server_incoming",
8
9
  ServerJoinServer = "server_join_server",
9
10
  ServerChangeTopology = "server_change_topology"
@@ -17,8 +18,8 @@ export declare class StatFirstMediaReceived {
17
18
  constructor(statAggregator: StatAggregator);
18
19
  markAcceptCall(topology: TransportTopology): void;
19
20
  markAcceptedCall(topology?: TransportTopology): void;
20
- markParticipantJoined(topology: TransportTopology): void;
21
21
  markOnJoin(topology: TransportTopology): void;
22
+ markTopologyChanged(topology: TransportTopology): void;
22
23
  private mark;
23
24
  measure(): void;
24
25
  }
@@ -9,7 +9,6 @@ import TransportTopology from '../enums/TransportTopology';
9
9
  import ConversationFeature from '../enums/ConversationFeature';
10
10
  import ConversationOption from '../enums/ConversationOption';
11
11
  import MediaOption from '../enums/MediaOption';
12
- import SignalingCommandType from '../enums/SignalingCommandType';
13
12
  import SignalingConnectionType from '../enums/SignalingConnectionType';
14
13
  import UserRole from '../enums/UserRole';
15
14
  import { type DebugLogger } from '../static/Debug';
@@ -26,29 +25,24 @@ import ParticipantLayout, { RequestKeyFrame, StopStream } from '../types/Partici
26
25
  import { ParticipantListChunkParameters } from '../types/ParticipantListChunk';
27
26
  import { StreamDescriptionString } from '../types/ParticipantStreamDescription';
28
27
  import { PerfStatReport } from '../types/PerfStatReporter';
29
- import SignalingMessage, { GetParticipantsSignalingResponse, GetRoomsSignalingResponse, SignalingSuccessResponse } from '../types/SignalingMessage';
28
+ import SignalingMessage, { GetParticipantsSignalingResponse, GetRoomsSignalingResponse } from '../types/SignalingMessage';
30
29
  import { IPublishStreamData, IStartStreamData, IStopStreamData } from '../types/Streams';
31
30
  export default class Signaling extends BaseSignaling {
32
- private socket;
33
- protected sequence: number;
31
+ private transport;
32
+ private sequence;
34
33
  private lastStamp;
35
34
  private websocketCommandsQueue;
36
35
  private datachannelCommandsQueue;
37
36
  private incomingCache;
38
37
  private responseHandlers;
39
38
  private connectionType;
40
- private reconnectCount;
41
- private endpoint;
42
- private wtEndpoint;
43
- protected conversationResolve: Function | null;
44
- protected conversationReject: Function | null;
39
+ private conversationResolve;
40
+ private conversationReject;
45
41
  private connected;
46
42
  private listenersReady;
47
- protected peerId: number | null;
48
- protected conversationId: string | null;
49
- private reconnectTimer;
43
+ private peerId;
44
+ private conversationId;
50
45
  private connectionMessageWaitTimer;
51
- private doctorTimer;
52
46
  private participantIdRegistry;
53
47
  private producerNotificationDataChannel;
54
48
  private producerCommandDataChannel;
@@ -57,16 +51,13 @@ export default class Signaling extends BaseSignaling {
57
51
  private readonly _debug;
58
52
  private readonly _logger;
59
53
  private readonly _statAggregator;
60
- private readonly _pings;
61
- private readonly _signalingCommands;
62
- private static get RECONNECT_DELAY();
63
- private static get RECONNECT_MAX_DELAY();
64
- private static get RECONNECT_MAX_COUNT();
54
+ private readonly _statPings;
55
+ private readonly _statSignalingCommands;
65
56
  private static get WAIT_CONNECTION_DELAY();
66
57
  private static get WAIT_RESPONSE_DELAY();
67
- private static get WAIT_MESSAGE_DELAY();
68
- constructor(debug?: DebugLogger, logger?: StatsLogger | null, statAggregator?: StatAggregator | null, pings?: StatPings | null, signalingCommands?: StatSignalingCommands | null);
69
58
  get ready(): boolean;
59
+ constructor(debug?: DebugLogger, logger?: StatsLogger | null, statAggregator?: StatAggregator | null, statPings?: StatPings | null, statSignalingCommands?: StatSignalingCommands | null);
60
+ setAbortSignal(signal: AbortSignal | undefined): void;
70
61
  setEndpoint(endpoint: string): void;
71
62
  setWebTransportEndpoint(endpoint: string | null): void;
72
63
  setConversationId(conversationId: string): void;
@@ -82,15 +73,6 @@ export default class Signaling extends BaseSignaling {
82
73
  * Open a connection with a signaling server
83
74
  */
84
75
  connect(connectionType: SignalingConnectionType): Promise<SignalingMessage.Connection>;
85
- /**
86
- * Send a command to a signaling server
87
- */
88
- protected _send<T extends SignalingSuccessResponse>(command: SignalingCommandType, params?: any, needResponse?: boolean, retryCount?: number): Promise<T>;
89
- /**
90
- * Send a raw command to a signaling server
91
- */
92
- protected _sendRaw<T extends SignalingSuccessResponse>(command: SignalingCommandType, params?: any, needResponse?: boolean, retryCount?: number): Promise<T>;
93
- private _isDataChannelCommand;
94
76
  getNextCommandSequenceNumber(): number;
95
77
  hangup(reason: string): Promise<SignalingMessage | void>;
96
78
  sendCandidate(participantId: ParticipantId, candidate: RTCIceCandidate): Promise<SignalingMessage>;
@@ -173,34 +155,36 @@ export default class Signaling extends BaseSignaling {
173
155
  startAsr(params: IAsrStartParams): Promise<SignalingMessage>;
174
156
  stopAsr(params?: IAsrStopParams): Promise<SignalingMessage>;
175
157
  requestAsr(request: boolean): Promise<SignalingMessage>;
176
- private _buildUrl;
177
- protected _connect(connectionType: SignalingConnectionType, useWebTransport: boolean): void;
178
- protected _disconnect(code?: number): void;
158
+ /**
159
+ * Send a command to a signaling server
160
+ */
161
+ private _send;
162
+ /**
163
+ * Send a raw command to a signaling server
164
+ */
165
+ private _sendRaw;
166
+ private _isDataChannelCommand;
179
167
  private _onOpen;
180
168
  private _onMessage;
181
- protected _handleMessage(message: SignalingMessage): void;
169
+ private _handleMessage;
182
170
  private _handleErrorMessage;
183
- protected _handleCachedMessages(): void;
171
+ private _handleCachedMessages;
184
172
  private _throwError;
185
173
  private _onError;
186
174
  private _serializeErrorEvent;
187
- protected _onClose(event: CloseEvent): void;
188
- protected _closeSocket(error?: Error | null): void;
189
- protected _reconnect(): void;
175
+ private _onClose;
176
+ private _closeSocket;
190
177
  private _handleCommandResponse;
191
178
  private _handleCommandsQueue;
192
179
  private _startResponseTimer;
193
180
  private _serializeBinary;
194
181
  private _serializeJson;
195
182
  private _convertDisplayLayout;
196
- protected _waitConnectionMessage(): void;
197
- protected _stopWaitConnectionMessage(): void;
198
- /**
199
- * Отвечает за timeout логику в WebSocket, если неполучаем никаких сообщений в течении WAIT_MESSAGE_DELAY, то запускаем реконнект
200
- */
201
- private _startDoctor;
202
- private _stopDoctor;
203
- private isWebTransportAvailable;
183
+ private _waitConnectionMessage;
184
+ private _stopWaitConnectionMessage;
185
+ private _onTransportFailed;
186
+ private _onTransportReconnectScheduled;
187
+ private _onTransportConnectionDead;
204
188
  private _getSocketType;
205
189
  private _markTransportStat;
206
190
  private _logTransportStat;
@@ -0,0 +1,68 @@
1
+ import SignalingConnectionType from '../enums/SignalingConnectionType';
2
+ import { SignalingTransportType } from '../enums/SignalingTransportStat';
3
+ export declare enum SignalingTransportFailure {
4
+ EMPTY_ENDPOINT = "EMPTY_ENDPOINT",
5
+ NETWORK_ERROR = "NETWORK_ERROR",
6
+ ABORTED = "ABORTED"
7
+ }
8
+ export type SignalingTransportFailedEvent = {
9
+ failure: SignalingTransportFailure;
10
+ message: string;
11
+ remote?: boolean;
12
+ };
13
+ export type SignalingTransportReconnectEvent = {
14
+ count: number;
15
+ delay: number;
16
+ };
17
+ export type SignalingTransportHandlers = {
18
+ onOpen: () => void;
19
+ onMessage: (event: MessageEvent) => void;
20
+ onError: (event: Event) => void;
21
+ onClose: (event: CloseEvent) => void;
22
+ onFailed: (event: SignalingTransportFailedEvent) => void;
23
+ onReconnectScheduled: (event: SignalingTransportReconnectEvent) => void;
24
+ onConnectionDead: () => void;
25
+ };
26
+ export default class SignalingTransport {
27
+ private readonly handlers;
28
+ private socket;
29
+ private endpoint;
30
+ private wtEndpoint;
31
+ private peerId;
32
+ private lastStamp;
33
+ private connectionType;
34
+ private reconnectCount;
35
+ private reconnectTimer;
36
+ private doctorTimer;
37
+ private forceWebSocket;
38
+ private abortSignal;
39
+ private manualClose;
40
+ private currentType;
41
+ constructor(handlers: SignalingTransportHandlers);
42
+ get readyState(): number | null;
43
+ get type(): SignalingTransportType;
44
+ setEndpoint(endpoint: string): void;
45
+ setWebTransportEndpoint(endpoint: string | null): void;
46
+ setPeerId(peerId: number | null): void;
47
+ setLastStamp(lastStamp: number): void;
48
+ setAbortSignal(signal?: AbortSignal): void;
49
+ resetReconnectCount(): void;
50
+ connect(connectionType: SignalingConnectionType): void;
51
+ close(code?: number): void;
52
+ send(data: string | ArrayBuffer): void;
53
+ private _connect;
54
+ private _connectWebTransport;
55
+ private _connectWebSocket;
56
+ private _setSocketHandlers;
57
+ private _buildUrl;
58
+ private _canUseWebTransport;
59
+ private _onOpen;
60
+ private _onMessage;
61
+ private _onError;
62
+ private _onClose;
63
+ private _disconnect;
64
+ private _scheduleReconnect;
65
+ private _getReconnectDelay;
66
+ private _startDoctor;
67
+ private _stopDoctor;
68
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vkontakte/calls-sdk",
3
- "version": "2.8.11-beta.3",
3
+ "version": "2.8.11-beta.4",
4
4
  "author": "vk.com",
5
5
  "description": "Library for video calls based on the vk.com platform",
6
6
  "homepage": "https://vk.com",
@@ -7,6 +7,8 @@ declare class WebTransportEventual {
7
7
  private readonly url;
8
8
  private readonly options;
9
9
  private readonly compression;
10
+ private closeRequested;
11
+ private closeEventEmitted;
10
12
  private encoder;
11
13
  private decoder;
12
14
  onopen: ((this: WebTransportEventual, ev: Event) => any) | null;
@@ -22,6 +24,8 @@ declare class WebTransportEventual {
22
24
  send(data: string): Promise<void>;
23
25
  private createErrorEvent;
24
26
  close(code?: number, reason?: string): void;
27
+ private closeConnectedTransport;
28
+ private emitClose;
25
29
  static isBrowserSupported(): boolean;
26
30
  }
27
31
  export { WebTransportEventual as WebTransport };