tgstation-server 6.12.0
The /tg/station 13 server suite
Loading...
Searching...
No Matches
ServerSwarm.cs
Go to the documentation of this file.
1using System;
2using System.Collections.Generic;
3using System.Linq;
4
5using HotChocolate;
6
7using Microsoft.Extensions.Options;
8
14
16{
20 public sealed class ServerSwarm
21 {
25 [TgsGraphQLAuthorize]
27
32 [TgsGraphQLAuthorize]
33 public Users Users() => new();
34
42 [Service] IOptionsSnapshot<SwarmConfiguration> swarmConfigurationOptions,
43 [Service] ISwarmService swarmService)
44 {
45 ArgumentNullException.ThrowIfNull(swarmConfigurationOptions);
46 ArgumentNullException.ThrowIfNull(swarmService);
47
48 var ourIdentifier = swarmConfigurationOptions.Value.Identifier;
49 if (ourIdentifier == null)
50 return new StandaloneNode();
51
52 return (IServerNode?)SwarmNode.GetSwarmNode(ourIdentifier, swarmService) ?? new StandaloneNode();
53 }
54
60 [TgsGraphQLAuthorize]
61 public List<SwarmNode>? Nodes(
62 [Service] ISwarmService swarmService)
63 {
64 ArgumentNullException.ThrowIfNull(swarmService);
65 return swarmService.GetSwarmServers()?.Select(x => new SwarmNode(x)).ToList();
66 }
67
72 [TgsGraphQLAuthorize]
74 }
75}
Represents a tgstation-server swarm.
List< SwarmNode >? Nodes([Service] ISwarmService swarmService)
Gets all SwarmNode servers in the swarm.
int ProtocolMajorVersion
Gets the swarm protocol major version in use.
Users Users()
Gets the swarm's Types.Users.
UpdateInformation UpdateInformation()
Gets the Types.UpdateInformation for the swarm.
IServerNode CurrentNode([Service] IOptionsSnapshot< SwarmConfiguration > swarmConfigurationOptions, [Service] ISwarmService swarmService)
Gets the connected SwarmNode server.
A IServerNode not running as part of a larger ServerSwarm.
Represents a node server in a swarm.
Definition SwarmNode.cs:23
static ? SwarmNode GetSwarmNode(string identifier, [Service] ISwarmService swarmService)
Node resolver for SwarmNodes.
Definition SwarmNode.cs:57
Gets information about updates for the ServerSwarm.
Wrapper for accessing Users.
Definition Users.cs:23
Attribute for bringing in the master versions list from MSBuild that aren't embedded into assemblies ...
string RawSwarmProtocolVersion
The Version string of the TGS swarm protocol.
static MasterVersionsAttribute Instance
Return the Assembly's instance of the MasterVersionsAttribute.
Represents a tgstation-server installation.
Used for swarm operations. Functions may be no-op based on configuration.