Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: Communicate with other connections #109

Open
SteveAndrews opened this issue Dec 27, 2020 · 4 comments
Open

Question: Communicate with other connections #109

SteveAndrews opened this issue Dec 27, 2020 · 4 comments

Comments

@SteveAndrews
Copy link

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?

@davidfowl
Copy link
Owner

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?

@RoccoDevs
Copy link

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

@SteveAndrews
Copy link
Author

SteveAndrews commented Feb 27, 2021

@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.

@davidfowl
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants