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

Surface Current ConnectionId in HubContext #93

Open
alfkonee opened this issue Aug 2, 2019 · 1 comment
Open

Surface Current ConnectionId in HubContext #93

alfkonee opened this issue Aug 2, 2019 · 1 comment

Comments

@alfkonee
Copy link

alfkonee commented Aug 2, 2019

Hello there,

Would it be possible to surface the Details about the connection of the current client in order to get the current client Connection Id

For instance in a scenario where you have send a notification back to only the calling client for particular User.
You could do something like
HubContext.CurrentClient.Send("MethodName", data )
OR
HubContext.Client(HubContext.CurrentConnectionId).Send("MethodName", data )

@stephenlautier
Copy link
Contributor

I dont believe this is possible. The HubContext its quite fairly simple class, and in the grain context you would not be are of the connectionId, unless you have it in your id; somehow you need to know who you intend to send to

Not 100% sure why would you need this, perhaps you can add more on it.

Generally how we use it in our application is:

  • If user is authenticated and we need to send to specific user (on all tabs/devices) we use User: _hubContext.User("123")
  • if we need to send to on a topic based on something we use Group e.g. _hubContext.Group($"hero:all")

If the above dont suffice, and you literally need to send only 1 message to the specific connectionId I suggest

  • On OnConnect (hub)
  • Get grain either pass the ConnectionId as part of the id or have a method .SetConnectionId (i suggest the as id, but might be difficult then to obtain the grain unless you will have connectionId)
  • Use _hubContext.Client("123")

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

2 participants