Open SteveAndrews opened 3 years ago
I could create a singleton DI class to inject into ConnectionHandlers, and have each request call into that to store it's info, but I wouldn't get close notifications.
Why not?
You can store the ConnectionContext in a ConcurrentDictionary somewhere. Those have everything u need on them. I have done something similar in here: https://github.com/tomesendam/RelayServer.Benchmarking/blob/main/src/TheDesolatedTunnels.RelayServer.Core/Services/ConnectionStore.cs
Which in turn is taken from: https://github.com/dotnet/aspnetcore/blob/cfc43b38e1d1c205fdac2cf15b994651f9520590/src/SignalR/server/Core/src/HubConnectionStore.cs
@tomesendam I implemented something similar, but now I am running into blocking issues. I'll look at the code you provided. I'm building something very similar to RelayServer (except starting from https://github.com/davidfowl/MultiProtocolAspNetCore) and I've been enormously frustrated by the lack of documentation on Microsoft stuff. Thank you.
This isn't Microsoft stuff, it's my stuff. Also it's not really a mainline scenario that's why the documentation is light. I can help if you share specifics on where you are stuck
How would I receive a message on a ConnectionHandler and then send a message to a different connection on the same listener? I can't raise an event from a ConnectionHandler because DI and referenced assemblies. I could put Server into a holding class and inject that, but Server doesn't expose enough underlying functionality. _listeners and _connections are both private. I could create a singleton DI class to inject into ConnectionHandlers, and have each request call into that to store it's info, but I wouldn't get close notifications. My requirement is conceptually similar to hub and spoke with groups in SignalR, and I'm trying to do this without modifying FW code. Is it possible with the current design?