Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What is the proper way to update connectPayload on reconnection? #1506

Open
ericgroom opened this issue Dec 9, 2024 · 0 comments
Open

What is the proper way to update connectPayload on reconnection? #1506

ericgroom opened this issue Dec 9, 2024 · 0 comments

Comments

@ericgroom
Copy link

So I have a client that passes auth and other info via the withPayload: parameter of SocketIOClient.connect. When I get a .reconnectAttempt client event, I want to update this payload to a new value. I see SocketIOClient stores this payload as connectPayload and passes it again, but the property is internal.

Calling SocketIOClient.connect within the event handler seems possible but like it has side effects. Same with SocketIOClient.joinNamespace. As I'm already reconnecting, I worry that calling one of these can cause a race condition in SocketManager._tryReconnect since they will call SocketManager.connect() internally before it is called in SocketManager._tryReconnect. Maybe unfounded, but nonetheless shouldn't there be a public way to update this value?

I think I can get around it by subclassing but that seems heavy handed...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant