therungg / therun-frontend

Frontend for therun.gg
https://therun-fr-therun.vercel.app
MIT License
26 stars 8 forks source link

Websocket Improvements #25

Closed dennisrijsdijk closed 1 year ago

dennisrijsdijk commented 1 year ago
dennisrijsdijk commented 1 year ago

Note: this should only be applied once the websocket doesn't reply to incoming messages.

florence-wolfe commented 1 year ago

@therungg Do you know if the multiple calls to the socket hook is spawning multiple connections? I haven't actually tested this myself but it would seem that this is what happens just based on the code.

The react-use-websocket lib has a shared option when instantiating that creates a proxied socket object for each attempted instantiation aiming to use the same URL (and new connections for new URLs). And then my understanding is that you're expected to use getWebsocket to retrieve the instance

https://github.com/robtaussig/react-use-websocket#getwebsocket