You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've seen #3119, and getting the token via query parameters, the initial WebSocket upgrade request, or the first message sent. What I'm interested in, however, is sending data to a specific user via subscriptions, a way of identifying connected users, then sending User A data that is relevant to User A.
A use case of this might be a leaderboard of User A's friends only. Assume User A is friends with User B, but not User Z. A would want real-time updates about B, but not Z's scores, as they aren't requested, and may violate Z's privacy. The only way I would think of this to be implemented is like so:
publicclassSubscription{[Subscribe][Authorize]publicUser?LeaderboardUpdated([AuthenticatedUser]UsercurrentUser,[EventMessage]UserupdatedUser){if(currentUser.Friend.Any(friend =>friend.ID==updatedUser.ID))returnnull;returnupdatedUser;}}[Authorize]publicasyncBookUpdateBook(UserupdatedUser,[Service]ITopicEventSendersender){awaitsender.SendAsync(nameof(Subscription.LeaderboardUpdated,book);// Omitted code for brevity}
User being a class with User.ID being a string and User.Friends being an IEnumerable<User>. If the check fails in this situation, would null, an empty string, I'm assuming, be sent to User Z, since User B isn't one of their friends, or would HC just ignore it?
If there is a better way, or something built into HC, please let me know, as I had to use SignalR for this specific part of a project, even though the rest of it is using HC.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I've seen #3119, and getting the token via query parameters, the initial WebSocket upgrade request, or the first message sent. What I'm interested in, however, is sending data to a specific user via subscriptions, a way of identifying connected users, then sending User A data that is relevant to User A.
A use case of this might be a leaderboard of User A's friends only. Assume User A is friends with User B, but not User Z. A would want real-time updates about B, but not Z's scores, as they aren't requested, and may violate Z's privacy. The only way I would think of this to be implemented is like so:
User
being a class withUser.ID
being a string andUser.Friends
being anIEnumerable<User>
. If the check fails in this situation, wouldnull
, an empty string, I'm assuming, be sent to User Z, since User B isn't one of their friends, or would HC just ignore it?If there is a better way, or something built into HC, please let me know, as I had to use SignalR for this specific part of a project, even though the rest of it is using HC.
Beta Was this translation helpful? Give feedback.
All reactions