forked from Unity-Technologies/go-ts3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver_cmds.go
499 lines (446 loc) · 23.8 KB
/
server_cmds.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
package ts3
import (
"time"
)
const (
// ExtendedServerList can be passed to List to get extended server information.
ExtendedServerList = "-extended"
)
// ServerMethods groups server methods.
type ServerMethods struct {
*Client
}
// Instance represents basic information for a TeamSpeak 3 instance.
type Instance struct {
DatabaseVersion int `ms:"serverinstance_database_version"`
FileTransferPort int `ms:"serverinstance_filetransfer_port"`
MaxTotalDownloadBandwidth uint64 `ms:"serverinstance_max_download_total_bandwidth"`
MaxTotalUploadBandwidth uint64 `ms:"serverinstance_max_upload_total_bandwidth"`
GuestServerQueryGroup int `ms:"serverinstance_guest_serverquery_group"`
ServerQueryFloodCommands int `ms:"serverinstance_serverquery_flood_commands"`
ServerQueryFloodTime int `ms:"serverinstance_serverquery_flood_time"`
ServerQueryBanTime int `ms:"serverinstance_serverquery_ban_time"`
TemplateServerAdminGroup int `ms:"serverinstance_template_serveradmin_group"`
TemplateServerDefaultGroup int `ms:"serverinstance_template_serverdefault_group"`
TemplateChannelAdminGroup int `ms:"serverinstance_template_channeladmin_group"`
TemplateChannelDefaultGroup int `ms:"serverinstance_template_channeldefault_group"`
PermissionsVersion int `ms:"serverinstance_permissions_version"`
PendingConnectionsPerIP int `ms:"serverinstance_pending_connections_per_ip"`
}
// ServerConnectionInfo represents the connection info for a TeamSpeak 3 instance.
type ServerConnectionInfo struct {
FileTransferBandwidthSent uint64 `ms:"connection_filetransfer_bandwidth_sent"`
FileTransferBandwidthReceived uint64 `ms:"connection_filetransfer_bandwidth_received"`
FileTransferTotalSent uint64 `ms:"connection_filetransfer_bytes_sent_total"`
FileTransferTotalReceived uint64 `ms:"connection_filetransfer_bytes_received_total"`
PacketsSentTotal uint64 `ms:"connection_packets_sent_total"`
PacketsReceivedTotal uint64 `ms:"connection_packets_received_total"`
BytesSentTotal uint64 `ms:"connection_bytes_sent_total"`
BytesReceivedTotal uint64 `ms:"connection_bytes_received_total"`
BandwidthSentLastSecond uint64 `ms:"connection_bandwidth_sent_last_second_total"`
BandwidthReceivedLastSecond uint64 `ms:"connection_bandwidth_received_last_second_total"`
BandwidthSentLastMinute uint64 `ms:"connection_bandwidth_sent_last_minute_total"`
BandwidthReceivedLastMinute uint64 `ms:"connection_bandwidth_received_last_minute_total"`
ConnectedTime uint32 `ms:"connection_connected_time"`
PacketLossTotalAvg float32 `ms:"connection_packetloss_total"`
PingTotalAvg float32 `ms:"connection_ping"`
PacketsSentSpeech uint64 `ms:"connection_packets_sent_speech"`
PacketsReceivedSpeech uint64 `ms:"connection_packets_received_speech"`
BytesSentSpeech uint64 `ms:"connection_bytes_sent_speech"`
BytesReceivedSpeech uint64 `ms:"connection_bytes_received_speech"`
PacketsSentKeepalive uint64 `ms:"connection_packets_sent_keepalive"`
PacketsReceivedKeepalive uint64 `ms:"connection_packets_received_keepalive"`
BytesSentKeepalive uint64 `ms:"connection_bytes_sent_keepalive"`
BytesReceivedKeepalive uint64 `ms:"connection_bytes_received_keepalive"`
PacketsSentControl uint64 `ms:"connection_packets_sent_control"`
PacketsReceivedControl uint64 `ms:"connection_packets_received_control"`
BytesSentControl uint64 `ms:"connection_bytes_sent_control"`
BytesReceivedControl uint64 `ms:"connection_bytes_received_control"`
}
// Server represents a TeamSpeak 3 virtual server.
type Server struct {
AntiFloodPointsNeededCommandBlock int `ms:"virtualserver_antiflood_points_needed_command_block"`
AntiFloodPointsNeededIPBlock int `ms:"virtualserver_antiflood_points_needed_ip_block"`
AntiFloodPointsTickReduce int `ms:"virtualserver_antiflood_points_tick_reduce"`
ChannelsOnline int `ms:"virtualserver_channelsonline"`
ClientsOnline int `ms:"virtualserver_clientsonline"`
CodecEncryptionMode int `ms:"virtualserver_codec_encryption_mode"`
ComplainAutoBanCount int `ms:"virtualserver_complain_autoban_count"`
ComplainAutoBanTime int `ms:"virtualserver_complain_autoban_time"`
ComplainRemoveTime int `ms:"virtualserver_complain_remove_time"`
Created int `ms:"virtualserver_created"`
DefaultChannelAdminGroup int `ms:"virtualserver_default_channel_admin_group"`
DefaultChannelGroup int `ms:"virtualserver_default_channel_group"`
DefaultServerGroup int `ms:"virtualserver_default_server_group"`
HostBannerGFXInterval int `ms:"virtualserver_hostbanner_gfx_interval"`
HostMessageMode int `ms:"virtualserver_hostmessage_mode"`
ID int `ms:"virtualserver_id"`
MachineID string `ms:"virtualserver_machine_id"`
MaxClients int `ms:"virtualserver_maxclients"`
MinClientsInChannelBeforeForcedSilence int `ms:"virtualserver_min_clients_in_channel_before_forced_silence"`
NeededIdentitySecurityLevel int `ms:"virtualserver_needed_identity_security_level"`
Port int `ms:"virtualserver_port"`
QueryClientsOnline int `ms:"virtualserver_queryclientsonline"`
Uptime int `ms:"virtualserver_uptime"` // TODO(steve): use time.Duration
AskForPrivilegeKey bool `ms:"virtualserver_ask_for_privilegekey"`
AutoStart bool `ms:"virtualserver_autostart"`
FlagPassword bool `ms:"virtualserver_flag_password"`
LogChannel bool `ms:"virtualserver_log_channel"`
LogClient bool `ms:"virtualserver_log_client"`
LogFileTransfer bool `ms:"virtualserver_log_filetransfer"`
LogPermissions bool `ms:"virtualserver_log_permissions"`
LogQuery bool `ms:"virtualserver_log_client"`
LogServer bool `ms:"virtualserver_log_server"`
WebListEnabled bool `ms:"virtualserver_web_list_enabled"`
PrioritySpeakerDimmModificator float32 `ms:"virtualserver_priority_speaker_dimm_modificator"`
BandwidthReceivedLastMinuteTotal int `ms:"virtualserver_bandwidth_received_last_minute_total"`
BandwidthReceivedLastSecondTotal int `ms:"virtualserver_bandwidth_received_last_second_total"`
BandwidthSentLastMinuteTotal int `ms:"virtualserver_bandwidth_sent_last_minute_total"`
BandwidthSentLastSecondTotal int `ms:"virtualserver_bandwidth_sent_last_second_total"`
ChannelTempDeleteDelayDefault int `ms:"virtualserver_channel_temp_delete_delay_default"`
HostBannerMode int `ms:"virtualserver_hostbanner_mode"`
IconID int `ms:"virtualserver_icon_id"`
MinAndroidVersion int `ms:"virtualserver_min_android_version"`
MinClientVersion int `ms:"virtualserver_min_client_version"`
MiniOSVersion int `ms:"virtualserver_min_ios_version"`
ReservedSlots int `ms:"virtualserver_reserved_slots"`
TotalPing float32 `ms:"virtualserver_total_ping"`
MaxDownloadTotalBandwidth uint64 `ms:"virtualserver_max_download_total_bandwidth"`
MaxUploadTotalBandwidth uint64 `ms:"virtualserver_max_upload_total_bandwidth"`
MonthBytesDownloaded int64 `ms:"virtualserver_month_bytes_downloaded"`
MonthBytesUploaded int64 `ms:"virtualserver_month_bytes_uploaded"`
TotalBytesDownloaded int64 `ms:"virtualserver_total_bytes_downloaded"`
TotalBytesUploaded int64 `ms:"virtualserver_total_bytes_uploaded"`
TotalPacketLossControl float64 `ms:"virtualserver_total_packetloss_control"`
TotalPacketLossKeepalive float64 `ms:"virtualserver_total_packetloss_keepalive"`
TotalPacketLossSpeech float64 `ms:"virtualserver_total_packetloss_speech"`
TotalPacketLossTotal float64 `ms:"virtualserver_total_packetloss_total"`
VirtualServerDownloadQuota uint64 `ms:"virtualserver_download_quota"`
VirtualServerUploadQuota uint64 `ms:"virtualserver_upload_quota"`
FileBase string `ms:"virtualserver_filebase"`
HostBannerGFXURL string `ms:"virtualserver_hostbanner_gfx_url"`
HostBannerURL string `ms:"virtualserver_hostbanner_url"`
HostButtonGFXURL string `ms:"virtualserver_hostbutton_gfx_url"`
HostButtonToolTip string `ms:"virtualserver_hostbutton_tooltip"`
HostButtonURL string `ms:"virtualserver_hostbutton_url"`
HostMessage string `ms:"virtualserver_hostmessage"`
Name string `ms:"virtualserver_name"`
NamePhonetic string `ms:"virtualserver_name_phonetic"`
Password string `ms:"virtualserver_password"`
Platform string `ms:"virtualserver_platform"`
Status string `ms:"virtualserver_status"`
UniqueIdentifier string `ms:"virtualserver_unique_identifier"`
Version string `ms:"virtualserver_version"`
WelcomeMessage string `ms:"virtualserver_welcomemessage"`
}
// List lists virtual servers.
// In addition to the options supported by the Teamspeak 3 query protocol it also supports the ExtendedServerList option.
// If ExtendedServerList is specified in options then each server returned contain extended server information as returned by Info.
func (s *ServerMethods) List(options ...string) (servers []*Server, err error) {
var extended bool
for i, o := range options {
if o == ExtendedServerList {
options = append(options[:i], options[i+1:]...)
extended = true
}
}
if _, err = s.ExecCmd(NewCmd("serverlist").WithOptions(options...).WithResponse(&servers)); err != nil {
return nil, err
}
if extended {
var info *ConnectionInfo
if info, err = s.Whoami(); err != nil {
return nil, err
}
var lastID int
defer func() {
if lastID != info.ServerID {
// Restore the previously selected server
if err2 := s.Use(info.ServerID); err2 != nil && err != nil {
err = err2
}
}
}()
for _, server := range servers {
if err = s.Use(server.ID); err != nil {
return nil, err
}
lastID = server.ID
if _, err = s.ExecCmd(NewCmd("serverinfo").WithResponse(server)); err != nil {
return nil, err
}
}
}
return servers, nil
}
// IDGetByPort returns the database id of the virtual server running on UDP port.
func (s *ServerMethods) IDGetByPort(port uint16) (int, error) {
r := struct {
ID int `ms:"server_id"`
}{}
_, err := s.ExecCmd(NewCmd("serveridgetbyport").WithArgs(NewArg("virtualserver_port", port)).WithResponse(&r))
return r.ID, err
}
// Info returns detailed configuration information about the selected server.
func (s *ServerMethods) Info() (*Server, error) {
r := &Server{}
if _, err := s.ExecCmd(NewCmd("serverinfo").WithResponse(&r)); err != nil {
return nil, err
}
return r, nil
}
// InstanceInfo returns detailed information about the selected instance.
func (s *ServerMethods) InstanceInfo() (*Instance, error) {
r := &Instance{}
if _, err := s.ExecCmd(NewCmd("instanceinfo").WithResponse(&r)); err != nil {
return nil, err
}
return r, nil
}
// ServerConnectionInfo returns detailed bandwidth and transfer information about the selected instance.
func (s *ServerMethods) ServerConnectionInfo() (*ServerConnectionInfo, error) {
r := &ServerConnectionInfo{}
if _, err := s.ExecCmd(NewCmd("serverrequestconnectioninfo").WithResponse(&r)); err != nil {
return nil, err
}
return r, nil
}
// Edit changes the selected virtual servers configuration using the given args.
func (s *ServerMethods) Edit(args ...CmdArg) error {
_, err := s.ExecCmd(NewCmd("serveredit").WithArgs(args...))
return err
}
// Delete deletes the virtual server specified by id.
// Only virtual server in a stopped state can be deleted.
func (s *ServerMethods) Delete(id int) error {
_, err := s.ExecCmd(NewCmd("serverdelete").WithArgs(NewArg("sid", id)))
return err
}
// CreatedServer is the details returned by a server create.
type CreatedServer struct {
ID int `ms:"sid"`
Port uint16 `ms:"virtualserver_port"`
Token string
}
// Create creates a new virtual server using the given properties and returns
// its ID, port and initial administrator privilege key.
// If virtualserver_port arg is not specified, the server will use the first unused
// UDP port.
func (s *ServerMethods) Create(name string, args ...CmdArg) (*CreatedServer, error) {
r := &CreatedServer{}
args = append(args, NewArg("virtualserver_name", name))
if _, err := s.ExecCmd(NewCmd("servercreate").WithArgs(args...).WithResponse(r)); err != nil {
return nil, err
}
return r, nil
}
// Start starts the virtual server specified by id.
func (s *ServerMethods) Start(id int) error {
_, err := s.ExecCmd(NewCmd("serverstart").WithArgs(NewArg("sid", id)))
return err
}
// Stop stops the virtual server specified by id.
func (s *ServerMethods) Stop(id int) error {
_, err := s.ExecCmd(NewCmd("serverstop").WithArgs(NewArg("sid", id)))
return err
}
// Group represents a virtual server group.
type Group struct {
ID int `ms:"sgid"`
Name string
Type int
IconID int
Saved bool `ms:"savedb"`
SortID int
NameMode int
ModifyPower int `ms:"n_modifyp"`
MemberAddPower int `ms:"n_member_addp"`
MemberRemovePower int `ms:"n_member_addp"`
}
// GroupList returns a list of available groups for the selected server.
func (s *ServerMethods) GroupList() ([]*Group, error) {
var groups []*Group
if _, err := s.ExecCmd(NewCmd("servergrouplist").WithResponse(&groups)); err != nil {
return nil, err
}
return groups, nil
}
// Channel represents a TeamSpeak 3 channel in a virtual server.
type Channel struct {
ID int `ms:"cid"`
ParentID int `ms:"pid"`
ChannelOrder int `ms:"channel_order"`
ChannelName string `ms:"channel_name"`
TotalClients int `ms:"total_clients"`
NeededSubscribePower int `ms:"channel_needed_subscribe_power"`
}
// ChannelList returns a list of channels for the selected server.
func (s *ServerMethods) ChannelList() ([]*Channel, error) {
var channels []*Channel
if _, err := s.ExecCmd(NewCmd("channellist").WithResponse(&channels)); err != nil {
return nil, err
}
return channels, nil
}
// PrivilegeKey represents a server privilege key.
type PrivilegeKey struct {
Token string
Type int `ms:"token_type"`
ID1 int `ms:"token_id1"`
ID2 int `ms:"token_id2"`
Created int `ms:"token_created"`
Description string `ms:"token_description"`
}
// PrivilegeKeyList returns a list of available privilege keys for the selected server,
// including their type and group IDs.
func (s *ServerMethods) PrivilegeKeyList() ([]*PrivilegeKey, error) {
var keys []*PrivilegeKey
if _, err := s.ExecCmd(NewCmd("privilegekeylist").WithResponse(&keys)); err != nil {
return nil, err
}
return keys, nil
}
// PrivilegeKeyAdd creates a new privilege token to the selected server and returns it.
// If tokentype is set to 0, the ID specified with id1 will be a server group ID.
// Otherwise, id1 is used as a channel group ID and you need to provide a valid channel ID using id2.
func (s *ServerMethods) PrivilegeKeyAdd(ttype, id1, id2 int, options ...CmdArg) (string, error) {
t := struct {
Token string
}{}
options = append(options, NewArg("tokentype", ttype), NewArg("tokenid1", id1), NewArg("tokenid2", id2))
_, err := s.ExecCmd(NewCmd("privilegekeylist").WithArgs(options...).WithResponse(&t))
return t.Token, err
}
// OnlineClient represents a client online on a virtual server.
type OnlineClient struct {
ID int `ms:"clid"`
ChannelID int `ms:"cid"`
DatabaseID int `ms:"client_database_id"`
Nickname string `ms:"client_nickname"`
Type int `ms:"client_type"`
Away bool `ms:"client_away"`
AwayMessage string `ms:"client_away_message"`
}
// DetailedOnlineClient extends OnlineClient with all information from the
// clientinfo server query command about a client online on a virtual server.
type DetailedOnlineClient struct {
OnlineClient `ms:",squash"`
// Creation date and time of the clients first connection to the server.
Created time.Time `ms:"client_created"`
// Termination date and time of the clients last connection to the server.
// Note: The manual claims this to be the *creation* date and time but the
// values received while testing suggest otherwise.
LastConnected time.Time `ms:"client_lastconnected"`
// Empty or a string of 32 hexadecimal characters. Indicates whether the
// client has set an avatar or not.
// What platform the client is running on. For example "Windows".
Base64HashClientUID string `ms:"client_base64HashClientUID"`
// For example "83.123.45.6". According to the manual this is always IPv4.
ConnectionClientIP string `ms:"connection_client_ip"`
// For example "DE" for Germany.
Country string `ms:"client_country"`
// Takes the form of "/channelID"
DefaultChannel string `ms:"client_default_channel"`
DefaultToken string `ms:"client_default_token"`
Description string `ms:"client_description"`
LoginName string `ms:"client_login_name"`
NicknamePhonetic string `ms:"client_nickname_phonetic"`
SecurityHash string `ms:"client_security_hash"`
TalkRequestMsg string `ms:"client_talk_request_msg"`
UniqueIdentifier string `ms:"client_unique_identifier"`
FlagAvatar string `ms:"client_flag_avatar"`
Platform string `ms:"client_platform"`
// Which version of the Teamspeak client application this client uses.
Version string `ms:"client_version"`
VersionSign string `ms:"client_version_sign"`
// Milliseconds since the client connected to the server.
ConnectionConnectedTime int64 `ms:"connection_connected_time"`
ConnectionBytesReceivedTotal int64 `ms:"connection_bytes_received_total"`
ConnectionBytesSentTotal int64 `ms:"connection_bytes_sent_total"`
ConnectionPacketsReceivedTotal int64 `ms:"connection_packets_received_total"`
ConnectionPacketsSentTotal int64 `ms:"connection_packets_sent_total"`
// Milliseconds since the client did something, for example sending
// a message, muting themselves or talking.
IdleTime int64 `ms:"client_idle_time"`
MonthBytesDownloaded int64 `ms:"client_month_bytes_downloaded"`
MonthBytesUploaded int64 `ms:"client_month_bytes_uploaded"`
TotalBytesDownloaded int64 `ms:"client_total_bytes_downloaded"`
TotalBytesUploaded int64 `ms:"client_total_bytes_uploaded"`
// Current bandwidth used for outgoing file transfers (Bytes/s)
ConnectionFiletransferBandwidthSent int `ms:"connection_filetransfer_bandwidth_sent"`
// Current bandwidth used for incoming file transfers (Bytes/s)
ConnectionFiletransferBandwidthReceived int `ms:"connection_filetransfer_bandwidth_received"`
// Average bandwidth used for outgoing data in the last second (Bytes/s)
ConnectionBandwidthSentLastSecondTotal int `ms:"connection_bandwidth_sent_last_second_total"`
// Average bandwidth used for outgoing data in the last minute (Bytes/s)
ConnectionBandwidthSentLastMinuteTotal int `ms:"connection_bandwidth_sent_last_minute_total"`
// Average bandwidth used for incoming data in the last second (Bytes/s)
ConnectionBandwidthReceivedLastSecondTotal int `ms:"connection_bandwidth_received_last_second_total"`
// Average bandwidth used for incoming data in the last minute (Bytes/s)
ConnectionBandwidthReceivedLastMinuteTotal int `ms:"connection_bandwidth_received_last_minute_total"`
ChannelGroupID int `ms:"client_channel_group_id"`
ChannelGroupInheritedChannelID int `ms:"client_channel_group_inherited_channel_id"`
NeededServerqueryViewPower int `ms:"client_needed_serverquery_view_power"`
Servergroups []int `ms:"client_servergroups"`
TalkPower int `ms:"client_talk_power"`
// How often the client has connected to the server.
Totalconnections int `ms:"client_totalconnections"`
// CRC32 checksum of the client icon
IconID uint32 `ms:"client_icon_id"`
// False if the client has their microphone disabled, for example
// because they unplugged it. Do not confuse this with InputMuted.
InputHardware bool `ms:"client_input_hardware"`
// True if the client has their microphone muted
InputMuted bool `ms:"client_input_muted"`
IsChannelCommander bool `ms:"client_is_channel_commander"`
IsPrioritySpeaker bool `ms:"client_is_priority_speaker"`
IsRecording bool `ms:"client_is_recording"`
// False if the client has their speakers disabled, for example
// because they are unplugged. Do not confuse this with OutputMuted.
OutputHardware bool `ms:"client_output_hardware"`
// True if the client has their speakers muted
OutputMuted bool `ms:"client_output_muted"`
OutputOnlyMuted bool `ms:"client_outputonly_muted"`
TalkRequest bool `ms:"client_talk_request"`
// Indicates whether the client is able to talk or not.
//TODO(Henner25): This is always 0, even if my talk power is high enough?
IsTalker bool `ms:"client_is_talker"`
//TODO(Henner25): I always got "overwolf=0". I assume it is a list of "key=value|key2=value2...". In that case, the type of this should be a map (or maybe an array, if it's only true/false).
//Badges string `ms:"client_badges"`
//TODO(Henner25): I never managed to receive any value for this field
//MetaData interface{} `ms:"client_meta_data"`
}
// ClientInfo returns detailed information about a single online client.
func (s *ServerMethods) ClientInfo(clientID int) (*DetailedOnlineClient, error) {
var client DetailedOnlineClient
if _, err := s.ExecCmd(NewCmd("clientinfo").WithArgs(NewArg("clid", clientID)).WithResponse(&client)); err != nil {
return nil, err
}
client.ID = clientID // the clientinfo command does not include the clid in the result set
return &client, nil
}
// ClientList returns a list of online clients.
func (s *ServerMethods) ClientList() ([]*OnlineClient, error) {
var clients []*OnlineClient
if _, err := s.ExecCmd(NewCmd("clientlist").WithResponse(&clients)); err != nil {
return nil, err
}
return clients, nil
}
// DBClient represents a client identity on a virtual server.
type DBClient struct {
ID int `ms:"cldbid"`
UniqueIdentifier string `ms:"client_unique_identifier"`
Nickname string `ms:"client_nickname"`
Created time.Time `ms:"client_created"`
LastConnected time.Time `ms:"client_lastconnected"`
Connections int `ms:"client_totalconnections"`
}
// ClientDBList returns a list of client identities known by the server.
func (s *ServerMethods) ClientDBList() ([]*DBClient, error) {
var dbclients []*DBClient
if _, err := s.ExecCmd(NewCmd("clientdblist").WithResponse(&dbclients)); err != nil {
return nil, err
}
return dbclients, nil
}