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
It would be great if useWebSocket could incorporate connection counting.
Rationale:
There are times where you may have multiple elements of an application that connect to the same websocket connection, e.g. video feeds, controls, chats etc, but which can be opened and closed independently of one another. If all are closed a websocket connection to the server would not be necessary (and therefore closed) but with one or more open it would be (and a connection would be established).
Only one connection would ever be needed, but a count would be required so that if three elements are opened and two closed the connect remains open. If all are closed the socket should be closed.
What to do:
Implement a connection tracker, that enables tracking the number of connections triggered per url, with the count incrementing with more connections and decrementing as per close request, with 0 connections being a complete close of connection. Only one actual websocket connection should ever be established per url.
This could be provided as an optional feature which definitely has its use cases. I've had to implement this myself in projects and it would be great to have something pre-built that could be quickly imported with optionality to access such functionality.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
It would be great if useWebSocket could incorporate connection counting.
Rationale:
There are times where you may have multiple elements of an application that connect to the same websocket connection, e.g. video feeds, controls, chats etc, but which can be opened and closed independently of one another. If all are closed a websocket connection to the server would not be necessary (and therefore closed) but with one or more open it would be (and a connection would be established).
Only one connection would ever be needed, but a count would be required so that if three elements are opened and two closed the connect remains open. If all are closed the socket should be closed.
What to do:
Implement a connection tracker, that enables tracking the number of connections triggered per url, with the count incrementing with more connections and decrementing as per close request, with 0 connections being a complete close of connection. Only one actual websocket connection should ever be established per url.
This could be provided as an optional feature which definitely has its use cases. I've had to implement this myself in projects and it would be great to have something pre-built that could be quickly imported with optionality to access such functionality.
Beta Was this translation helpful? Give feedback.
All reactions