C
C#2mo ago
Alex

✅ what's the difference?

What's the difference between sending message to signalR endpoint directly and sending post to controller and execute it hubcinnection.sendasync method inside of it? I want to build game project based on signalr, one person draws the picture other guess what is it by typing it in chat. Can I use only one connection for both sending drawn pixels and chat messages? Should I send chat messages directly to signalR hub of to the post route of controller?
2 Replies
Sossenbinder
Sossenbinder2mo ago
You can even have multiple hubs using a single websocket connection, if I recall correctly it will be multiplexed under the hood. You can also use signalr for bidirectional connection, but there are some drawbacks. First, if signalr uses e.g. websockets, you are bound to a long lasting http connection, and you will not be able to profit from something like round robin load balancing. Then you are also not forced to "respond" to a request, so the client might be left hanging unless you build a request reply setup yourself With http through a controller you just get to benefit from the entire streamlined pipeline built around it, and your client will always receive some response back (Plus you are not bound to a more specific protocol in case you want to provide your API to someone else down the road)
Alex
Alex2mo ago
thank you, I understand