Skip to content

Commit 930f6ac

Browse files
review fix, add urlConfigFunctionParameters to pass state into implementing transport config.url()
1 parent 93dcfc8 commit 930f6ac

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

src/transports/websocket.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,14 @@ export class WebSocketClassProvider {
3131
}
3232
}
3333

34+
/**
35+
* Object used to pass partial websocket transport state into url config function.
36+
*/
37+
export interface WebSocketUrlConfigFunctionParameters {
38+
/** Number of times streamHandler was called without a responsive connection */
39+
streamHandlerInvocationsWithNoConnection: number
40+
}
41+
3442
/**
3543
* Config object that is provided to the WebSocketTransport constructor.
3644
*/
@@ -39,6 +47,7 @@ export interface WebSocketTransportConfig<T extends WebsocketTransportGenerics>
3947
url: (
4048
context: EndpointContext<T>,
4149
desiredSubs: TypeFromDefinition<T['Parameters']>[],
50+
urlConfigFunctionParameters: WebSocketUrlConfigFunctionParameters,
4251
) => Promise<string> | string
4352

4453
/** Optional parameters used when establishing the WebSocket connection */
@@ -468,7 +477,9 @@ export class WebSocketTransport<
468477
context: EndpointContext<T>,
469478
subscriptions: SubscriptionDeltas<TypeFromDefinition<T['Parameters']>>,
470479
): Promise<{ urlChanged: boolean; url: string }> {
471-
const url = await this.config.url(context, subscriptions.desired)
480+
const url = await this.config.url(context, subscriptions.desired, {
481+
streamHandlerInvocationsWithNoConnection: this.streamHandlerInvocationsWithNoConnection,
482+
})
472483
const urlChanged = this.currentUrl !== url
473484
return { urlChanged, url }
474485
}

0 commit comments

Comments
 (0)