tgstation-server 6.12.0
The /tg/station 13 server suite
Loading...
Searching...
No Matches
UserSubscriptions.cs
Go to the documentation of this file.
1using System;
5
6using HotChocolate;
10
14
16{
21 [GraphQLDescription(Subscription.GraphQLDescription)]
22 public sealed class UserSubscriptions
23 {
27 const string UserUpdatedTopic = "UserUpdated";
28
39
45 static string SpecificUserUpdatedTopic(long userId)
46 => $"{UserUpdatedTopic}.{userId}";
47
64
73 {
74 ArgumentNullException.ThrowIfNull(user);
75 return user;
76 }
77
87 [Service] IAuthenticationContext authenticationContext,
88 CancellationToken cancellationToken)
89 {
91 ArgumentNullException.ThrowIfNull(authenticationContext);
92 return receiver.SubscribeAsync<User>(SpecificUserUpdatedTopic(Models.ModelExtensions.Require(authenticationContext.User, user => user.Id)), cancellationToken);
93 }
94
103 {
104 ArgumentNullException.ThrowIfNull(user);
105
106 return user;
107 }
108 }
109}
Root type for GraphQL subscriptions.
const string GraphQLDescription
Description to show on the Subscription type.
static string SpecificUserUpdatedTopic(long userId)
The name of the topic for when a specific Models.User is updated.
static IEnumerable< string > UserUpdatedTopics(long userId)
Get the names of the topics to send to when a Models.User is updated.
ValueTask< ISourceStream< User > > CurrentUserUpdatedStream([Service] ITopicEventReceiver receiver, [Service] IAuthenticationContext authenticationContext, CancellationToken cancellationToken)
ISourceStream for CurrentUserUpdated(User).
ValueTask< ISourceStream< User > > UserUpdatedStream([ID(nameof(User))] long? userId, [Service] ITopicEventReceiver receiver, CancellationToken cancellationToken)
ISourceStream for UserUpdated(User).
User CurrentUserUpdated([EventMessage] User user)
Receive an update to the logged in User when it is changed.
User UserUpdated([EventMessage] User user)
Receive an update for all User changes.
const string UserUpdatedTopic
The name of the topic for when any user is updated.
A user registered in the server.
Definition User.cs:21
Implementation of HotChocolate.Subscriptions.ITopicEventReceiver that works around the global::System...
For creating and accessing authentication contexts.
@ List
User may list files if the Models.Instance allows it.
AdministrationRights
Administration rights for the server.