tgstation-server 5.12.7
The /tg/station 13 server suite
Loading...
Searching...
No Matches
TopicParameters.cs
Go to the documentation of this file.
1using System;
2
3using Newtonsoft.Json;
4
6
8{
13 {
19
23 public ChatCommand ChatCommand { get; }
24
29
33 public ushort? NewPort { get; }
34
38 public RebootState? NewRebootState { get; }
39
43 public string NewInstanceName { get; }
44
48 public ChatUpdate ChatUpdate { get; }
49
53 public Version NewServerVersion { get; }
54
58 public ChunkData Chunk { get; }
59
63 [JsonIgnore]
64 public bool IsPriority => CommandType switch
65 {
66 TopicCommandType.EventNotification
67 or TopicCommandType.ChangePort
68 or TopicCommandType.ChangeRebootState
69 or TopicCommandType.InstanceRenamed
70 or TopicCommandType.ChatChannelsUpdate
71 or TopicCommandType.ServerRestarted => true,
72 TopicCommandType.ChatCommand
73 or TopicCommandType.HealthCheck
74 or TopicCommandType.ReceiveChunk => false,
75 TopicCommandType.SendChunk => throw new InvalidOperationException("SendChunk topic priority should be based on the original TopicParameters!"),
76 _ => throw new InvalidOperationException($"Invalid value for {nameof(CommandType)}: {CommandType}"),
77 };
78
83 public TopicParameters(ChatCommand chatCommand)
85 {
86 ChatCommand = chatCommand ?? throw new ArgumentNullException(nameof(chatCommand));
87 }
88
93 public TopicParameters(EventNotification eventNotification)
95 {
96 EventNotification = eventNotification ?? throw new ArgumentNullException(nameof(eventNotification));
97 }
98
103 public TopicParameters(ushort newPort)
104 : this(TopicCommandType.ChangePort)
105 {
106 NewPort = newPort;
107 }
108
113 public TopicParameters(RebootState newRebootState)
114 : this(TopicCommandType.ChangeRebootState)
115 {
116 NewRebootState = newRebootState;
117 }
118
123 public TopicParameters(string newInstanceName)
124 : this(TopicCommandType.InstanceRenamed)
125 {
126 NewInstanceName = newInstanceName ?? throw new ArgumentNullException(nameof(newInstanceName));
127 }
128
133 public TopicParameters(ChatUpdate channelsUpdate)
134 : this(TopicCommandType.ChatChannelsUpdate)
135 {
136 ChatUpdate = channelsUpdate ?? throw new ArgumentNullException(nameof(channelsUpdate));
137 }
138
144 public TopicParameters(Version newServerVersion, ushort serverPort)
145 : this(TopicCommandType.ServerRestarted)
146 {
147 NewServerVersion = newServerVersion ?? throw new ArgumentNullException(nameof(newServerVersion));
148 NewPort = serverPort;
149 }
150
156 : this(TopicCommandType.SendChunk)
157 {
158 Chunk = chunk ?? throw new ArgumentNullException(nameof(chunk));
159 }
160
166 : this(TopicCommandType.HealthCheck)
167 {
168 }
169
174 protected TopicParameters(TopicCommandType commandType)
175 {
176 CommandType = commandType;
177 }
178 }
179}
Represents an update of ChannelRepresentations.
Definition: ChatUpdate.cs:13
A packet of a split serialized set of data.
Definition: ChunkData.cs:7
Represents a chat command to be handled by DD.
Definition: ChatCommand.cs:11
Data structure for TopicCommandType.EventNotification requests.
TopicParameters(RebootState newRebootState)
Initializes a new instance of the TopicParameters class.
TopicParameters(ChatCommand chatCommand)
Initializes a new instance of the TopicParameters class.
RebootState? NewRebootState
The RebootState for TopicCommandType.ChangeRebootState requests.
string NewInstanceName
The new Api.Models.NamedEntity.Name for TopicCommandType.InstanceRenamed requests.
Version NewServerVersion
The new server Version after a reattach.
ChunkData Chunk
The ChunkData for a partial request.
ushort? NewPort
The new port for TopicCommandType.ChangePort or TopicCommandType.ServerPortUpdate requests.
TopicParameters(EventNotification eventNotification)
Initializes a new instance of the TopicParameters class.
TopicParameters(ushort newPort)
Initializes a new instance of the TopicParameters class.
TopicParameters(string newInstanceName)
Initializes a new instance of the TopicParameters class.
TopicParameters()
Initializes a new instance of the TopicParameters class.
TopicParameters(TopicCommandType commandType)
Initializes a new instance of the TopicParameters class.
bool IsPriority
Whether or not the TopicParameters constitute a priority request.
TopicParameters(ChatUpdate channelsUpdate)
Initializes a new instance of the TopicParameters class.
TopicParameters(ChunkData chunk)
Initializes a new instance of the TopicParameters class.
TopicParameters(Version newServerVersion, ushort serverPort)
Initializes a new instance of the TopicParameters class.
TopicCommandType
The type of topic command being sent.
RebootState
Represents the action to take when /world/Reboot() is called.
Definition: RebootState.cs:7