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

Losing websocket callback handlers when calling socketFor #167

Open
ramster-vinka opened this issue Jan 3, 2019 · 0 comments
Open

Losing websocket callback handlers when calling socketFor #167

ramster-vinka opened this issue Jan 3, 2019 · 0 comments

Comments

@ramster-vinka
Copy link

Using SocketIO. I wonder if I'm using this correctly, but I'm losing callbacks in the actual socket object when socketFor is called during the socket is in disconnected state and the proxy object is updated with a new socket instance.

Initialize:

let socket = this.socketIOService.socketFor(url);
socket.on('myEvent', this.myHandler, this);

After this socket.listeners and socket.socket._callbacks contain all the added listeners.

Now if socket gets disconnected and I call again:
this.socketIOService.socketFor(url);

Inside socketFor function this.isWebSocketOpen(existingProxy.socket) is false -> new socket is created and set to existingProxy:
set(existingProxy, 'socket', newWebSocket);

After this socket.listeners contain added listeners, but socket.socket._callbacks does not. It only holds the default connecting and connect callbacks.

Is there something that I'm missing in the usage? Based on the examples socketFor seems to be a function that can be called several times. If I save the socket instance into a property and never call socketFor again, callbacks are working.

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