You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am connecting to a broker that expects an auth-token header on every CONNECT, SUBSCRIBE, UNSUBSCRIBE and DISCONNECT message. If the token that is sent is bad, it will disconnect the websocket.
I would like a clean mechanism by which to proactively ensure the token I am sending is good, rather than cleaning up the mess in an onError callback. This mechanism must of course be async so that I am able to refresh the token before sending, should this be necessary.
The interceptor pattern is commonly used with HTTP clients. It could be applied here also:
before any message is sent, allow the execution of a chain of client-provided asynchronous functions that can make arbitrary modifications to that frame, before forwarding along the chain, ultimately terminating in the library's client.send method. Something like:
intercept(frame: IFrame): Promise<IFrame>
The text was updated successfully, but these errors were encountered:
I get your problem and I believe that the approach you have suggested is proper. Would you like to submit a PR or you would like me to make the change?
I am connecting to a broker that expects an
auth-token
header on everyCONNECT
,SUBSCRIBE
,UNSUBSCRIBE
andDISCONNECT
message. If the token that is sent is bad, it will disconnect the websocket.I would like a clean mechanism by which to proactively ensure the token I am sending is good, rather than cleaning up the mess in an onError callback. This mechanism must of course be async so that I am able to refresh the token before sending, should this be necessary.
The interceptor pattern is commonly used with HTTP clients. It could be applied here also:
before any message is sent, allow the execution of a chain of client-provided asynchronous functions that can make arbitrary modifications to that frame, before forwarding along the chain, ultimately terminating in the library's client.send method. Something like:
The text was updated successfully, but these errors were encountered: