Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extended OnlineClient information variables #43

Merged
merged 6 commits into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mockserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ var commands = map[string]string{
"instanceinfo": "serverinstance_database_version=26 serverinstance_filetransfer_port=30033 serverinstance_max_download_total_bandwidth=18446744073709551615 serverinstance_max_upload_total_bandwidth=18446744073709551615 serverinstance_guest_serverquery_group=1 serverinstance_serverquery_flood_commands=50 serverinstance_serverquery_flood_time=3 serverinstance_serverquery_ban_time=600 serverinstance_template_serveradmin_group=3 serverinstance_template_serverdefault_group=5 serverinstance_template_channeladmin_group=1 serverinstance_template_channeldefault_group=4 serverinstance_permissions_version=19 serverinstance_pending_connections_per_ip=0",
"serverrequestconnectioninfo": "connection_filetransfer_bandwidth_sent=0 connection_filetransfer_bandwidth_received=0 connection_filetransfer_bytes_sent_total=617 connection_filetransfer_bytes_received_total=0 connection_packets_sent_total=926413 connection_bytes_sent_total=92911395 connection_packets_received_total=650335 connection_bytes_received_total=61940731 connection_bandwidth_sent_last_second_total=0 connection_bandwidth_sent_last_minute_total=0 connection_bandwidth_received_last_second_total=0 connection_bandwidth_received_last_minute_total=0 connection_connected_time=49408 connection_packetloss_total=0.0000 connection_ping=0.0000 connection_packets_sent_speech=320432180 connection_bytes_sent_speech=43805818511 connection_packets_received_speech=174885295 connection_bytes_received_speech=24127808273 connection_packets_sent_keepalive=55230363 connection_bytes_sent_keepalive=2264444883 connection_packets_received_keepalive=55149547 connection_bytes_received_keepalive=2316390993 connection_packets_sent_control=2376088 connection_bytes_sent_control=525691022 connection_packets_received_control=2376138 connection_bytes_received_control=227044870",
"channellist": "cid=499 pid=0 channel_order=0 channel_name=Default\\sChannel total_clients=1 channel_needed_subscribe_power=0",
"clientlist": "clid=5 cid=7 client_database_id=40 client_nickname=ScP client_type=0 client_away=1 client_away_message=not\\shere",
"clientlist": `clid=42087 cid=39 client_database_id=19 client_nickname=bdeb1337 client_type=0 client_away=1 client_away_message client_flag_talking=0 client_input_muted=0 client_output_muted=0 client_input_hardware=1 client_output_hardware=1 client_talk_power=75 client_is_talker=0 client_is_priority_speaker=0 client_is_recording=0 client_is_channel_commander=0 client_unique_identifier=DZhdQU58qyooEK4Fr8Ly738hEmc= client_servergroups=6,8 client_channel_group_id=8 client_channel_group_inherited_channel_id=39 client_version=3.6.1\s[Build:\s1690193193] client_platform=OS\sX client_idle_time=1280228 client_created=1661793049 client_lastconnected=1691527133 client_icon_id=0 client_country=BE connection_client_ip=1.3.3.7 client_badges`,
"clientdblist": "cldbid=7 client_unique_identifier=DZhdQU58qyooEK4Fr8Ly738hEmc= client_nickname=MuhChy client_created=1259147468 client_lastconnected=1259421233",
"whoami": "virtualserver_status=online virtualserver_id=18 virtualserver_unique_identifier=gNITtWtKs9+Uh3L4LKv8\\/YHsn5c= virtualserver_port=9987 client_id=94 client_channel_id=432 client_nickname=serveradmin\\sfrom\\s127.0.0.1:49725 client_database_id=1 client_login_name=serveradmin client_unique_identifier=serveradmin client_origin_server_id=0",
cmdQuit: "",
Expand Down
40 changes: 32 additions & 8 deletions server_cmds.go
Original file line number Diff line number Diff line change
Expand Up @@ -351,19 +351,43 @@ func (s *ServerMethods) PrivilegeKeyAdd(ttype, id1, id2 int, options ...CmdArg)

// 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"`
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"`
FlagTalking bool `ms:"client_flag_talking"`
InputMuted bool `ms:"client_input_muted"`
OutputMuted bool `ms:"client_output_muted"`
InputHardware bool `ms:"client_input_hardware"`
OutputHardware bool `ms:"client_output_hardware"`
TalkPower int `ms:"client_talk_power"`
IsTalker bool `ms:"client_is_talker"`
IsPrioritySpeaker bool `ms:"client_is_priority_speaker"`
IsRecording bool `ms:"client_is_recording"`
IsChannelCommander bool `ms:"client_is_channel_commander"`
UniqueIdentifier string `ms:"client_unique_identifier"`
ChannelGroupID int `ms:"client_channel_group_id"`
ChannelGroupInheritedChannelID int `ms:"client_channel_group_inherited_channel_id"`
Version string `ms:"client_version"`
Platform string `ms:"client_platform"`
IdleTime int `ms:"client_idle_time"`
Created int `ms:"client_created"`
LastConnected int `ms:"client_lastconnected"`
IconID int `ms:"client_icon_id"`
Country string `ms:"client_country"`
IP string `ms:"connection_client_ip"`
Badges string `ms:"client_badges"`
// TODO:
// ServerGroups []int `ms:"client_servergroups"`
bdeb1337 marked this conversation as resolved.
Show resolved Hide resolved
bdeb1337 marked this conversation as resolved.
Show resolved Hide resolved
}

// 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 {
if _, err := s.ExecCmd(NewCmd("clientlist -uid -away -voice -times -groups -info -icon -country -ip -badges").WithResponse(&clients)); err != nil {
return nil, err
}
return clients, nil
Expand Down
36 changes: 29 additions & 7 deletions server_cmds_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,13 +306,35 @@ func testCmdsServer(t *testing.T, c *Client) {

expected := []*OnlineClient{
{
ID: 5,
ChannelID: 7,
DatabaseID: 40,
Nickname: "ScP",
Type: 0,
Away: true,
AwayMessage: "not here",
ID: 42087,
ChannelID: 39,
DatabaseID: 19,
Nickname: "bdeb1337",
Type: 0,
Away: true,
AwayMessage: "",
FlagTalking: false,
InputMuted: false,
OutputMuted: false,
InputHardware: true,
OutputHardware: true,
TalkPower: 75,
IsTalker: false,
IsPrioritySpeaker: false,
IsRecording: false,
IsChannelCommander: false,
UniqueIdentifier: "DZhdQU58qyooEK4Fr8Ly738hEmc=",
ChannelGroupID: 8,
ChannelGroupInheritedChannelID: 39,
Version: "3.6.1 [Build: 1690193193]",
Platform: "OS X",
IdleTime: 1280228,
Created: 1661793049,
LastConnected: 1691527133,
IconID: 0,
Country: "BE",
IP: "1.3.3.7",
Badges: "",
},
}

Expand Down