Is there any advantages of having two distinct websocket connections to the same server from the same client? To me this seems a bad design choice, but is there any reason why/where it should work out better?
相关问题
- Is there a limit to how many levels you can nest i
- How to toggle on Order in ReactJS
- void before promise syntax
- Keeping track of variable instances
- Can php detect if javascript is on or not?
There are several reasons why you might want to do that but they probably aren't too common (at least not yet):
I'm sure there are other reasons but that's all I can think of off the top of my head.
I found that it can make client logic much simpler when you are only subscribing to updates of certain objects being managed by the server. Instead of devising a custom subscription protocol for a single channel, you can just open a socket for each element.
Let's say you obtained a collection of elements via a REST API at
You could subscribe to updates of a single element using a socket url like this:
Of course one can argue that this doesn't scale for complex pages. However, for small and simple appications it might make your life a lot easier.
I am currently searching for a solution for having two connections to the same websocket. My reason: