using System; namespace axXez.TS3.Protocol { /// Represents a TeamSpeak client returned by clientlist or clientinfo. public class ClientInfo : TsEntity, INamedEntity, IPlatformVersion { // --- Identity --- /// Client ID (session-based, changes on reconnect). [TsField("client_id", "clid")] public int ID { get; protected set; } /// Unique identifier of the client. [TsField("client_unique_identifier")] public string UID { get; protected set; } /// Current nickname of the client. [TsField("client_nickname")] public string Name { get; protected set; } /// Permanent database ID of the client. [TsField("client_database_id", "cldbid")] public int DBID { get; protected set; } /// Whether this is a regular voice client or a ServerQuery client. [TsField("client_type")] public ClientType Type { get; protected set; } // --- Location --- /// ID of the channel the client is currently in. [TsField("cid", "ctid")] public int ChannelID { get; protected set; } /// ID of the channel group assigned to the client in their current channel. [TsField("client_channel_group_id")] public int ChannelGroupID { get; protected set; } /// ID of the channel from which the client's channel group permissions are inherited. [TsField("client_channel_group_inherited_channel_id")] public int ChannelGroupInheritedChannelID { get; protected set; } /// Comma-separated list of server group IDs the client belongs to. [TsField("client_servergroups")] public string ServerGroups { get; protected set; } // --- Voice / Hardware --- /// Whether the client's microphone is muted. [TsField("client_input_muted")] public bool InputMuted { get; protected set; } /// Whether the client's speakers are muted. [TsField("client_output_muted")] public bool OutputMuted { get; protected set; } /// Whether the client is in output-only (speakers muted, mic active) mode. [TsField("client_outputonly_muted")] public bool OutputOnlyMuted { get; protected set; } /// Whether the client has a functioning input device (microphone). [TsField("client_input_hardware")] public bool InputEnabled { get; protected set; } /// Whether the client has a functioning output device (speakers). [TsField("client_output_hardware")] public bool OutputEnabled { get; protected set; } /// Whether the client is currently talking. [TsField("client_flag_talking")] public bool Talking { get; protected set; } /// Whether the client is currently recording. [TsField("client_is_recording")] public bool Recording { get; protected set; } /// Whether the client is a priority speaker in their channel. [TsField("client_is_priority_speaker")] public bool PrioritySpeaker { get; protected set; } /// Whether the client has channel commander mode enabled. [TsField("client_is_channel_commander")] public bool ChannelCommander { get; protected set; } // --- Away --- /// Whether the client is currently set as away. [TsField("client_away")] public bool Away { get; protected set; } /// The away message set by the client, if any. [TsField("client_away_message")] public string AwayMessage { get; protected set; } // --- Talk --- /// Talk power value assigned to the client. [TsField("client_talk_power")] public int TalkPower { get; protected set; } /// Whether the client has an active talk power request. [TsField("client_talk_request")] public bool RequestTalkPower { get; protected set; } /// Message accompanying the client's talk power request. [TsField("client_talk_request_msg")] public string RequestTalkPowerMessage { get; protected set; } /// Whether the client has been granted talker status. [TsField("client_is_talker")] public bool Talker { get; protected set; } // --- Client Info --- /// Client application version string. [TsField("client_version")] public string Version { get; protected set; } /// Operating system platform of the client. [TsField("client_platform")] public string Platform { get; protected set; } /// Cryptographic signature of the client's version build. [TsField("client_version_sign")] public string VersionSign { get; protected set; } /// Security hash used for client identity verification. [TsField("client_security_hash")] public string SecurityHash { get; protected set; } /// Login name for query clients; empty for regular voice clients. [TsField("client_login_name")] public string QueryLoginName { get; protected set; } /// Default channel path the client automatically connects to on join. [TsField("client_default_channel")] public string DefaultChannel { get; protected set; } /// Arbitrary metadata string set by the client. [TsField("client_meta_data")] public string MetaData { get; protected set; } /// Description text set on the client's profile. [TsField("client_description")] public string Description { get; protected set; } /// Phonetic pronunciation of the client's nickname, used by text-to-speech. [TsField("client_nickname_phonetic")] public string PhoneticName { get; protected set; } /// Icon ID displayed on the client. [TsField("client_icon_id")] public int IconID { get; protected set; } /// Two-letter country code derived from the client's IP address. [TsField("client_country")] public string Country { get; protected set; } /// MD5 hash of the client's avatar image; empty if no avatar is set. [TsField("client_flag_avatar")] public string AvatarFlag { get; protected set; } /// Minimum server query view power required to see this client. [TsField("client_needed_serverquery_view_power")] public int NeededQueryViewPower { get; protected set; } /// Default privilege key token assigned to the client. [TsField("client_default_token")] public string DefaultToken { get; protected set; } // --- MyTeamSpeak --- /// MyTeamSpeak account ID linked to the client. [TsField("client_myteamspeak_id")] public string MyTeamSpeakID { get; protected set; } /// MyTeamSpeak integration identifiers. [TsField("client_integrations")] public string Integrations { get; protected set; } /// Avatar URL or identifier from the client's MyTeamSpeak account. [TsField("client_myteamspeak_avatar")] public string MyTeamSpeakAvatar { get; protected set; } /// Raw badges string (e.g. "Overwolf=0"). [TsField("client_badges")] public string Badges { get; protected set; } /// Comma-separated list of cryptographically signed badge UUIDs. [TsField("client_signed_badges")] public string SignedBadges { get; protected set; } /// Base64-encoded hash of the client's UID, used for client identification. [TsField("client_base64HashClientUID")] public string Base64HashClientUID { get; protected set; } // --- Stats --- /// Time the client has been idle. [TsField("client_idle_time")] public TimeSpan IdleTime { get; protected set; } /// Date and time of the client's first connection to this server. [TsField("client_created")] public DateTime FirstConnection { get; protected set; } /// Date and time of the client's most recent connection. [TsField("client_lastconnected")] public DateTime LastConnection { get; protected set; } /// Total number of times the client has connected to this server. [TsField("client_totalconnections")] public int ConnectionCount { get; protected set; } /// Bytes uploaded by the client during the current calendar month. [TsField("client_month_bytes_uploaded")] public ulong BytesUploadedLastMonth { get; protected set; } /// Bytes downloaded by the client during the current calendar month. [TsField("client_month_bytes_downloaded")] public ulong BytesDownloadedLastMonth { get; protected set; } /// Total bytes uploaded by the client across all connections. [TsField("client_total_bytes_uploaded")] public ulong TotalBytesUploaded { get; protected set; } /// Total bytes downloaded by the client across all connections. [TsField("client_total_bytes_downloaded")] public ulong TotalBytesDownloaded { get; protected set; } // --- Connection (clientinfo only) --- /// Client IP address (only available in clientinfo responses). [TsField("connection_client_ip")] public string IP { get; protected set; } /// Duration since the client connected in the current session (only available in clientinfo responses). [TsField("connection_connected_time")] public TimeSpan ConnectedTime { get; protected set; } /// Current file transfer upload bandwidth in bytes/s (only available in clientinfo responses). [TsField("connection_filetransfer_bandwidth_sent")] public ulong FileTransferBandwidthSent { get; protected set; } /// Current file transfer download bandwidth in bytes/s (only available in clientinfo responses). [TsField("connection_filetransfer_bandwidth_received")] public ulong FileTransferBandwidthReceived { get; protected set; } /// Total UDP packets sent by the client in this session (only available in clientinfo responses). [TsField("connection_packets_sent_total")] public ulong PacketsSent { get; protected set; } /// Total bytes sent by the client in this session (only available in clientinfo responses). [TsField("connection_bytes_sent_total")] public ulong BytesSent { get; protected set; } /// Total UDP packets received by the client in this session (only available in clientinfo responses). [TsField("connection_packets_received_total")] public ulong PacketsReceived { get; protected set; } /// Total bytes received by the client in this session (only available in clientinfo responses). [TsField("connection_bytes_received_total")] public ulong BytesReceived { get; protected set; } /// Average outgoing bandwidth over the last second in bytes/s (only available in clientinfo responses). [TsField("connection_bandwidth_sent_last_second_total")] public ulong BandwidthSentLastSecond { get; protected set; } /// Average outgoing bandwidth over the last minute in bytes/s (only available in clientinfo responses). [TsField("connection_bandwidth_sent_last_minute_total")] public ulong BandwidthSentLastMinute { get; protected set; } /// Average incoming bandwidth over the last second in bytes/s (only available in clientinfo responses). [TsField("connection_bandwidth_received_last_second_total")] public ulong BandwidthReceivedLastSecond { get; protected set; } /// Average incoming bandwidth over the last minute in bytes/s (only available in clientinfo responses). [TsField("connection_bandwidth_received_last_minute_total")] public ulong BandwidthReceivedLastMinute { get; protected set; } internal ClientInfo(TsDataEntry data) : base(data) { } /// public override string ToString() => $"Client[{ID}] {Name}"; /// public override int GetHashCode() => ID.GetHashCode(); /// public override bool Equals(object obj) => obj is ClientInfo && ID.Equals((obj as ClientInfo).ID); } }