Updating URL in between onClose reconnects
redi-tjandr opened this issue · 2 comments
So I have a case where my URL contains an OAuth token (for authentication), kind of like this:
ws://localhost:8080/myapp/webapi/subscriptions?bearer_token=aba58cfd6ecbb9532e6308683d2accbd
It is possible that the session gets closed because the token is invalid (due to a timed out access token). In this case I would want to refresh my access token, update the URL and then try again to reconnect. I think, if we add an optional callback that this framework allowed to update the URL in between reconnects that would solve the problem. Something like this:
"function setUrlBetweenReconnects() {
... callback code here
}"
Or alternatively, if we specify an optional parameter string, that can be updated between reconnects, so initially I would set parameters to be "bearer_token=aba58cfd6ecbb9532e6308683d2accbd" and then in between reconnects you call "updateParameters()" which calls a method I set/override.
Any of this seem reasonable or can you think of a better way to solve this problem?
Wait, looks like I can just add an onclose event listener that gets called by the API. Perhaps the README could include a section on event listeners and usage. Sorry for the false issue.
@redi-tjandr the url
parameter is absolute. Could you provide some code example of updating token in url with onclose
listener?