@ipcom/asterisk-ari 0.0.152 → 0.0.153
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.
|
@@ -14,87 +14,57 @@ export declare class WebSocketClient extends EventEmitter {
|
|
|
14
14
|
private ws?;
|
|
15
15
|
private isReconnecting;
|
|
16
16
|
private readonly maxReconnectAttempts;
|
|
17
|
-
private reconnectionAttempts;
|
|
18
|
-
private lastWsUrl;
|
|
19
17
|
private readonly backOffOptions;
|
|
20
18
|
/**
|
|
21
|
-
* Creates a new
|
|
19
|
+
* Creates a new WebSocket client instance.
|
|
22
20
|
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* @param
|
|
27
|
-
* @param apps - An array of application names to connect to via the WebSocket.
|
|
28
|
-
* @param subscribedEvents - Optional. An array of WebSocketEventTypes to subscribe to. If not provided, all events will be subscribed.
|
|
29
|
-
* @param ariClient - Optional. The AriClient instance, used for creating Channel and Playback instances when processing events.
|
|
30
|
-
*
|
|
31
|
-
* @throws {Error} Throws an error if the apps array is empty.
|
|
21
|
+
* @param {BaseClient} baseClient - The base client containing connection details
|
|
22
|
+
* @param {string[]} apps - List of applications to connect to
|
|
23
|
+
* @param {WebSocketEventType[]} [subscribedEvents] - Optional list of events to subscribe to
|
|
24
|
+
* @param {AriClient} [ariClient] - Optional ARI client for handling channel and playback events
|
|
32
25
|
*/
|
|
33
26
|
constructor(baseClient: BaseClient, apps: string[], subscribedEvents?: WebSocketEventType[] | undefined, ariClient?: AriClient | undefined);
|
|
34
27
|
/**
|
|
35
|
-
* Establishes a WebSocket connection
|
|
28
|
+
* Establishes a WebSocket connection.
|
|
36
29
|
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
* using the constructed URL.
|
|
40
|
-
*
|
|
41
|
-
* @returns A Promise that resolves when the WebSocket connection is successfully established.
|
|
42
|
-
* @throws Will throw an error if the connection cannot be established.
|
|
30
|
+
* @returns {Promise<void>} Resolves when connection is established
|
|
31
|
+
* @throws {Error} If connection fails
|
|
43
32
|
*/
|
|
44
33
|
connect(): Promise<void>;
|
|
45
34
|
/**
|
|
46
|
-
* Initializes
|
|
47
|
-
*
|
|
48
|
-
* This method attempts to establish a WebSocket connection to the specified URL.
|
|
49
|
-
* It sets up event listeners for the WebSocket's 'open', 'message', 'close', and 'error' events.
|
|
50
|
-
* If the connection is successful, it emits a 'connected' event. If it's a reconnection,
|
|
51
|
-
* it also emits a 'reconnected' event with the current apps and subscribed events.
|
|
52
|
-
* In case of connection failure, it uses an exponential backoff strategy to retry.
|
|
35
|
+
* Initializes WebSocket connection with reconnection logic.
|
|
53
36
|
*
|
|
54
|
-
* @param wsUrl - The WebSocket URL to connect to
|
|
55
|
-
* @returns
|
|
56
|
-
* or rejects if an error occurs during the connection process.
|
|
57
|
-
* @throws Will throw an error if the WebSocket connection cannot be established
|
|
58
|
-
* after the maximum number of retry attempts.
|
|
37
|
+
* @param {string} wsUrl - The WebSocket URL to connect to
|
|
38
|
+
* @returns {Promise<void>} Resolves when connection is established
|
|
59
39
|
*/
|
|
60
40
|
private initializeWebSocket;
|
|
61
41
|
/**
|
|
62
|
-
*
|
|
42
|
+
* Processes incoming WebSocket messages.
|
|
63
43
|
*
|
|
64
|
-
*
|
|
65
|
-
* subscribed events (if any), processes channel and playback events, and emits
|
|
66
|
-
* the event to listeners. It also handles any errors that occur during processing.
|
|
67
|
-
*
|
|
68
|
-
* @param rawMessage - The raw message string received from the WebSocket connection.
|
|
69
|
-
* @returns void This method doesn't return a value but emits events.
|
|
70
|
-
*
|
|
71
|
-
* @throws Will emit an 'error' event if the message cannot be parsed or processed.
|
|
44
|
+
* @param {string} rawMessage - The raw message received from WebSocket
|
|
72
45
|
*/
|
|
73
46
|
private handleMessage;
|
|
74
47
|
/**
|
|
75
|
-
* Attempts to reconnect to the WebSocket
|
|
76
|
-
*
|
|
77
|
-
* This method is called when the WebSocket connection is closed unexpectedly.
|
|
78
|
-
* It increments the reconnection attempt counter, logs the attempt, and uses
|
|
79
|
-
* the backOff utility to retry the connection with exponential delays between attempts.
|
|
80
|
-
*
|
|
81
|
-
* @param wsUrl - The WebSocket URL to reconnect to.
|
|
82
|
-
* @returns void - This method doesn't return a value.
|
|
48
|
+
* Attempts to reconnect to the WebSocket.
|
|
83
49
|
*
|
|
84
|
-
* @
|
|
50
|
+
* @param {string} wsUrl - The WebSocket URL to reconnect to
|
|
85
51
|
*/
|
|
86
52
|
private reconnect;
|
|
87
53
|
/**
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
* This method attempts to gracefully close the WebSocket connection
|
|
91
|
-
* and sets the WebSocket instance to undefined. If an error occurs
|
|
92
|
-
* during the closing process, it will be caught and logged.
|
|
93
|
-
*
|
|
94
|
-
* @throws {Error} Logs an error message if closing the WebSocket fails.
|
|
54
|
+
* Manually closes the WebSocket connection.
|
|
95
55
|
*/
|
|
96
56
|
close(): void;
|
|
57
|
+
/**
|
|
58
|
+
* Checks if the WebSocket is currently connected.
|
|
59
|
+
*
|
|
60
|
+
* @returns {boolean} True if connected, false otherwise
|
|
61
|
+
*/
|
|
97
62
|
isConnected(): boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Gets the current connection state.
|
|
65
|
+
*
|
|
66
|
+
* @returns {number} The WebSocket ready state
|
|
67
|
+
*/
|
|
98
68
|
getState(): number;
|
|
99
69
|
}
|
|
100
70
|
//# sourceMappingURL=websocketClient.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"websocketClient.d.ts","sourceRoot":"","sources":["../../../src/ari-client/websocketClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAGtC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,EAAkB,kBAAkB,EAAE,MAAM,cAAc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