react-stomp-hooks
react-stomp-hooks copied to clipboard
Connect few sockets through provider
Hey! How can i add few connections. Because i have 2 sevices and each other have separate websocket connection. Heres 2 urls which i want connect
//
<StompSessionProvider
// url={${BASE_URL()}/users/v1/open/notifications-websocket
}
url={${BASE_URL()}/lessons/v1/open/websocket/drawboards
}
debug={STOMP => console.log({STOMP})}
connectHeaders={{Authorization: getAuthorizationHeader()}}
onConnect={() => console.log({STOMP_CONNECT: 'TCP connection successfully established'})}
reconnectDelay={1}
>
<ApplicationRoutes/>
<ReactQueryDevtools/>
</StompSessionProvider>
I guess maybe you need to separate in two different contexts
Hello!
As mixtoism correctly said, this is currently only possible by using multiple StompSessionProviders, which then only allows you to use one connection per subtree.
I will leave this ticket open as a feature request.
Hello!
As mixtoism correctly said, this is currently only possible by using multiple StompSessionProviders, which then only allows you to use one connection per subtree.
I will leave this ticket open as a feature request.
Hi @SvenKirschbaum , can we have this feature in V3?
Hello! As mixtoism correctly said, this is currently only possible by using multiple StompSessionProviders, which then only allows you to use one connection per subtree. I will leave this ticket open as a feature request.
Hi @SvenKirschbaum , can we have this feature in V3?
Yes, I plan on supporting this usecase in v3. You can expect an release early next week.
I have just release version 3.0.0, which allows nesting multiple StompSessionProviders. You can set a name property on the provider, which can then be passed to the hooks and hocs as well, to control which connection they refer to.
Let me know if you encounter any issues with this solution.