proto: TeamSpeak 6 fields and stream messages; tsctl shows streams

- Declarations: client_is_streaming (Client::is_streaming), initserver
  virtualserver_address/virtualserver_version_sign, stream
  notifications and commands (setupstream, stopstream, ...).
- tsctl: prints stream notifications and streaming state changes, marks
  streaming clients in the tree.
- CI: cargo-deny with default features (rug/GMP is benchmark-only).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NJvYyRmTjKcb9i8eyYXK5G
This commit is contained in:
Claude committed 2026-09-25 13:20:16 +00:00
1 parent cb5a541a3f
commit 369cbde85d
7 files changed
+132 -10

No files matched your search

+4
View File
@@ -60,7 +60,11 @@ jobs:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
# Default features only: the optional `rug` puzzle backend (GMP, LGPL) is
# benchmark-only and never shipped.
- uses: EmbarkStudios/cargo-deny-action@v2
with:
arguments: --workspace
smoke:
name: integration smoke (TS3 + TS6)
+8
View File
@@ -43,3 +43,11 @@ against or offered back to upstream.
`spawn_blocking` thread that stops when the connect future is dropped. The level
cap is `max_puzzle_level()` (default 100 million, was a fixed 10 million),
adjustable with `set_max_puzzle_level`, because TeamSpeak 6 adapts the level.
4. **TeamSpeak 6 declarations** (`tsproto-structs/declarations/Messages.toml`, `Book.toml`).
New fields `client_is_streaming` (book: `Client::is_streaming: Option<bool>`),
`virtualserver_address`, `virtualserver_version_sign`; stream notifications
(`notifystreamstarted`, `notifystreamstopped`, `notifystreaminfo`,
`notifyjoinstreamrequest`, `notifyrespondjoinstreamrequest`,
`notifystreamsignaling`, `notifystreamclientjoined`, `notifystreamclientleft`) and
commands (`setupstream`, `stopstream`, `streamsignaling`, `respondjoinstreamrequest`,
`removeclientfromstream`). See `docs/protocol-notes/ts6-streaming.md`.
@@ -170,6 +170,7 @@ properties = [
{ name="TalkPowerGranted", type="bool", doc="If the client is granted talk power" },
{ name="Metadata", type="str", doc="Set by client" },
{ name="IsRecording", type="bool", doc="Whether the client is recording" },
{ name="IsStreaming", type="bool", opt=true, doc="Whether the client is streaming (TeamSpeak 6), `None` on servers that do not report it" },
{ name="DatabaseId", type="ClientDbId" },
{ name="ChannelGroup", type="ChannelGroupId" },
{ name="ServerGroups", type="ServerGroupId", mod="set" },
@@ -411,6 +411,23 @@ fields = [
{ map="virtualserver_country", ts="virtualserver_country_code", pretty="CountryCode", type="str" },
{ map="virtualserver_default_music_group", ts="virtualserver_default_music_group", pretty="DefaultMusicGroup", type="ServerGroupId" },
{ map="root", ts="root", pretty="RootKey", type="str" },
# TeamSpeak 6 (observed on 6.0.0-beta13.1)
{ map="client_is_streaming", ts="client_is_streaming", pretty="IsStreaming", type="bool" },
{ map="virtualserver_address", ts="virtualserver_address", pretty="Address", type="str" },
{ map="virtualserver_version_sign", ts="virtualserver_version_sign", pretty="VersionSign", type="str" },
# TeamSpeak 6 streams, see docs/protocol-notes/ts6-streaming.md
{ map="id@stream", ts="id", pretty="StreamId", type="str" },
{ map="name@stream", ts="name", pretty="StreamName", type="str" },
{ map="type@stream", ts="type", pretty="StreamType", type="u8" },
{ map="access@stream", ts="access", pretty="Access", type="u8" },
{ map="accessibility@stream", ts="accessibility", pretty="Access", type="u8" },
{ map="mode@stream", ts="mode", pretty="StreamMode", type="u8" },
{ map="bitrate@stream", ts="bitrate", pretty="Bitrate", type="u32" },
{ map="viewer_limit@stream", ts="viewer_limit", pretty="ViewerLimit", type="u32" },
{ map="audio@stream", ts="audio", pretty="Audio", type="bool" },
{ map="json@stream", ts="json", pretty="Json", type="str" },
{ map="offer@stream", ts="offer", pretty="Offer", type="str" },
{ map="decision@stream", ts="decision", pretty="Accepted", type="bool" },
]
# The "msg_group: array specifies all messages which can be sent between client
@@ -459,25 +476,36 @@ msg = [
{ name="ClientChatComposing", notify="notifyclientchatcomposing", attributes=["clid", "cluid"] },
{ name="ClientConnectionInfo", notify="notifyconnectioninfo", attributes=["clid", "connection_ping?", "connection_ping_deviation?", "connection_connected_time?", "connection_client_ip?", "connection_client_port?", "connection_packets_sent_speech?", "connection_packets_sent_keepalive?", "connection_packets_sent_control?", "connection_bytes_sent_speech?", "connection_bytes_sent_keepalive?", "connection_bytes_sent_control?", "connection_packets_received_speech?", "connection_packets_received_keepalive?", "connection_packets_received_control?", "connection_bytes_received_speech?", "connection_bytes_received_keepalive?", "connection_bytes_received_control?", "connection_server2client_packetloss_speech?", "connection_server2client_packetloss_keepalive?", "connection_server2client_packetloss_control?", "connection_server2client_packetloss_total?", "connection_client2server_packetloss_speech", "connection_client2server_packetloss_keepalive", "connection_client2server_packetloss_control", "connection_client2server_packetloss_total", "connection_bandwidth_sent_last_second_speech?", "connection_bandwidth_sent_last_second_keepalive?", "connection_bandwidth_sent_last_second_control?", "connection_bandwidth_sent_last_minute_speech?", "connection_bandwidth_sent_last_minute_keepalive?", "connection_bandwidth_sent_last_minute_control?", "connection_bandwidth_received_last_second_speech?", "connection_bandwidth_received_last_second_keepalive?", "connection_bandwidth_received_last_second_control?", "connection_bandwidth_received_last_minute_speech?", "connection_bandwidth_received_last_minute_keepalive?", "connection_bandwidth_received_last_minute_control?", "connection_filetransfer_bandwidth_sent?", "connection_filetransfer_bandwidth_received?", "connection_idle_time"] },
{ name="ClientConnectionInfoUpdateRequest", notify="notifyconnectioninforequest", attributes=[] },
{ name="ClientEnterView", notify="notifycliententerview", attributes=["reasonid", "ctid", "invokerid?", "invokername?", "invokeruid?", "clid", "client_database_id", "client_nickname", "client_type", "cfid", "client_unique_identifier", "client_flag_avatar", "client_description", "client_icon_id", "client_input_muted", "client_output_muted", "client_outputonly_muted", "client_input_hardware", "client_output_hardware", "client_meta_data", "client_is_recording", "client_channel_group_id", "client_channel_group_inherited_channel_id", "client_servergroups", "client_away", "client_away_message", "client_talk_power", "client_talk_request", "client_talk_request_msg", "client_is_talker", "client_is_priority_speaker", "client_unread_messages", "client_nickname_phonetic", "client_needed_serverquery_view_power", "client_is_channel_commander", "client_country", "client_badges", "client_myteamspeak_id", "client_integrations", "client_myteamspeak_avatar?", "client_signed_badges?", "client_estimated_location?", "client_totalconnections?", "client_user_tag?"] },
{ name="ClientEnterView", notify="notifycliententerview", attributes=["reasonid", "ctid", "invokerid?", "invokername?", "invokeruid?", "clid", "client_database_id", "client_nickname", "client_type", "cfid", "client_unique_identifier", "client_flag_avatar", "client_description", "client_icon_id", "client_input_muted", "client_output_muted", "client_outputonly_muted", "client_input_hardware", "client_output_hardware", "client_meta_data", "client_is_recording", "client_channel_group_id", "client_channel_group_inherited_channel_id", "client_servergroups", "client_away", "client_away_message", "client_talk_power", "client_talk_request", "client_talk_request_msg", "client_is_talker", "client_is_priority_speaker", "client_unread_messages", "client_nickname_phonetic", "client_needed_serverquery_view_power", "client_is_channel_commander", "client_country", "client_badges", "client_myteamspeak_id", "client_integrations", "client_myteamspeak_avatar?", "client_signed_badges?", "client_estimated_location?", "client_totalconnections?", "client_user_tag?", "client_is_streaming?"] },
{ name="ClientLeftView", notify="notifyclientleftview", attributes=["reasonmsg?", "bantime?", "reasonid?", "ctid", "invokerid?", "invokername?", "invokeruid?", "clid", "cfid"] },
{ name="ClientMoved", notify="notifyclientmoved", attributes=["clid", "reasonid", "cfid?", "ctid", "invokerid?", "invokername?", "invokeruid?", "reasonmsg?"] },
{ name="ClientNeededPermissions", notify="notifyclientneededpermissions", attributes=["permid", "permvalue?"] },
{ name="ClientPermissionHints", notify="notifyclientpermhints", attributes=["clid", "flags@client_ph"] },
{ name="ClientServerGroupAdded", notify="notifyservergroupclientadded", attributes=["name", "sgid", "invokerid", "invokername", "invokeruid?", "clid", "cluid"] },
{ name="ClientServerGroupRemoved", notify="notifyservergroupclientdeleted", attributes=["name", "sgid", "invokerid", "invokername", "invokeruid?", "clid", "cluid"] },
{ name="ClientUpdated", notify="notifyclientupdated", attributes=["clid", "invokerid?", "invokername?", "invokeruid?", "client_nickname?", "client_unread_messages?", "client_version?", "client_platform?", "client_login_name?", "client_created?", "client_lastconnected?", "client_totalconnections?", "client_month_bytes_uploaded?", "client_month_bytes_downloaded?", "client_total_bytes_uploaded?", "client_total_bytes_downloaded?", "client_input_muted?", "client_input_hardware?", "client_output_muted?", "client_meta_data?", "client_output_hardware?", "client_description?", "client_is_priority_speaker?", "client_is_channel_commander?", "client_flag_avatar?", "client_signed_badges?", "client_talk_request?", "client_talk_request_msg?", "client_is_talker?", "client_nickname_phonetic?", "client_is_recording?", "client_servergroups?", "client_myteamspeak_id?", "client_badges?", "client_myteamspeak_avatar?", "client_talk_power?", "client_icon_id?", "client_away?", "client_away_message?", "client_channel_group_inherited_channel_id?", "client_channel_group_id?", "client_needed_serverquery_view_power?", "client_user_tag?"] },
{ name="ClientUpdated", notify="notifyclientupdated", attributes=["clid", "invokerid?", "invokername?", "invokeruid?", "client_nickname?", "client_unread_messages?", "client_version?", "client_platform?", "client_login_name?", "client_created?", "client_lastconnected?", "client_totalconnections?", "client_month_bytes_uploaded?", "client_month_bytes_downloaded?", "client_total_bytes_uploaded?", "client_total_bytes_downloaded?", "client_input_muted?", "client_input_hardware?", "client_output_muted?", "client_meta_data?", "client_output_hardware?", "client_description?", "client_is_priority_speaker?", "client_is_channel_commander?", "client_flag_avatar?", "client_signed_badges?", "client_talk_request?", "client_talk_request_msg?", "client_is_talker?", "client_nickname_phonetic?", "client_is_recording?", "client_servergroups?", "client_myteamspeak_id?", "client_badges?", "client_myteamspeak_avatar?", "client_talk_power?", "client_icon_id?", "client_away?", "client_away_message?", "client_channel_group_inherited_channel_id?", "client_channel_group_id?", "client_needed_serverquery_view_power?", "client_user_tag?", "client_is_streaming?"] },
{ name="CommandError", notify="error", attributes=["error_id", "msg", "failed_permid?", "return_code?", "extra_msg?"] },
{ name="FileListFinished", notify="notifyfilelistfinished", attributes=["cid", "path"] },
{ name="FiletransferStatus", notify="notifystatusfiletransfer", attributes=["clientftfid", "status@err", "msg", "size"] },
{ name="InitIvExpand", notify="initivexpand", attributes=["alpha", "beta", "omega"] },
{ name="InitIvExpand2", notify="initivexpand2", attributes=["l", "beta", "omega", "ot?", "proof", "tvd", "time@initivexpand2?", "root?"] },
{ name="InitServer", notify="initserver", attributes=["virtualserver_name", "virtualserver_welcomemessage", "virtualserver_platform", "virtualserver_version", "virtualserver_maxclients", "virtualserver_created", "virtualserver_codec_encryption_mode", "virtualserver_hostmessage", "virtualserver_hostmessage_mode", "virtualserver_default_server_group", "virtualserver_default_channel_group", "virtualserver_id", "virtualserver_ip?", "virtualserver_ask_for_privilegekey", "lt?", "virtualserver_hostbanner_url", "virtualserver_hostbanner_gfx_url", "virtualserver_hostbanner_gfx_interval", "virtualserver_priority_speaker_dimm_modificator", "virtualserver_hostbutton_tooltip", "virtualserver_hostbutton_url", "virtualserver_hostbutton_gfx_url", "virtualserver_name_phonetic", "virtualserver_icon_id", "virtualserver_hostbanner_mode", "virtualserver_channel_temp_delete_delay_default", "virtualserver_nickname?", "virtualserver_unique_identifier?", "virtualserver_default_music_group?", "virtualserver_default_channel_admin_group?", "virtualserver_weblist_enabled?", "virtualserver_country?", "virtualserver_capability_extensions?", "virtualserver_administrative_domain?", "client_nickname@initserver?", "client_version@initserver?", "client_platform@initserver?", "client_input_muted?", "client_output_muted?", "client_outputonly_muted?", "client_input_hardware?", "client_output_hardware?", "client_default_channel?", "client_default_channel_password?", "client_server_password?", "client_meta_data?", "client_version_sign@initserver?", "client_security_hash?", "client_key_offset?", "client_away?", "client_away_message?", "client_nickname_phonetic@initserver?", "client_default_token?", "client_badges?", "client_myteamspeak_id?", "client_integrations?", "client_active_integrations_info?", "client_myteamspeak_avatar?", "client_signed_badges?", "acn", "aclid", "pv", "client_talk_power", "client_needed_serverquery_view_power", "client_user_tag?"] },
{ name="InitServer", notify="initserver", attributes=["virtualserver_name", "virtualserver_welcomemessage", "virtualserver_platform", "virtualserver_version", "virtualserver_maxclients", "virtualserver_created", "virtualserver_codec_encryption_mode", "virtualserver_hostmessage", "virtualserver_hostmessage_mode", "virtualserver_default_server_group", "virtualserver_default_channel_group", "virtualserver_id", "virtualserver_ip?", "virtualserver_ask_for_privilegekey", "lt?", "virtualserver_hostbanner_url", "virtualserver_hostbanner_gfx_url", "virtualserver_hostbanner_gfx_interval", "virtualserver_priority_speaker_dimm_modificator", "virtualserver_hostbutton_tooltip", "virtualserver_hostbutton_url", "virtualserver_hostbutton_gfx_url", "virtualserver_name_phonetic", "virtualserver_icon_id", "virtualserver_hostbanner_mode", "virtualserver_channel_temp_delete_delay_default", "virtualserver_nickname?", "virtualserver_unique_identifier?", "virtualserver_default_music_group?", "virtualserver_default_channel_admin_group?", "virtualserver_weblist_enabled?", "virtualserver_country?", "virtualserver_capability_extensions?", "virtualserver_administrative_domain?", "client_nickname@initserver?", "client_version@initserver?", "client_platform@initserver?", "client_input_muted?", "client_output_muted?", "client_outputonly_muted?", "client_input_hardware?", "client_output_hardware?", "client_default_channel?", "client_default_channel_password?", "client_server_password?", "client_meta_data?", "client_version_sign@initserver?", "client_security_hash?", "client_key_offset?", "client_away?", "client_away_message?", "client_nickname_phonetic@initserver?", "client_default_token?", "client_badges?", "client_myteamspeak_id?", "client_integrations?", "client_active_integrations_info?", "client_myteamspeak_avatar?", "client_signed_badges?", "acn", "aclid", "pv", "client_talk_power", "client_needed_serverquery_view_power", "client_user_tag?", "virtualserver_address?", "virtualserver_version_sign?", "client_is_streaming?"] },
{ name="PluginCommand", notify="notifyplugincmd", attributes=["name", "data", "invokerid?", "invokername?", "invokeruid?"] },
{ name="ServerEdited", notify="notifyserveredited", attributes=["invokerid", "invokername", "invokeruid?", "reasonid", "virtualserver_name?", "virtualserver_nickname?", "virtualserver_codec_encryption_mode?", "virtualserver_default_server_group?", "virtualserver_default_channel_group?", "virtualserver_hostbanner_url?", "virtualserver_hostbanner_gfx_url?", "virtualserver_hostbanner_gfx_interval?", "virtualserver_priority_speaker_dimm_modificator?", "virtualserver_hostbutton_tooltip?", "virtualserver_hostbutton_url?", "virtualserver_hostbutton_gfx_url?", "virtualserver_name_phonetic?", "virtualserver_icon_id?", "virtualserver_hostbanner_mode?", "virtualserver_channel_temp_delete_delay_default?" ] },
{ name="ServerTempPasswordList", notify="notifyservertemppasswordlist", attributes=["nickname", "uid", "desc", "pw_clear", "start@tmppw", "end", "tcid", "tcpw"] },
{ name="ServerUpdated", notify="notifyserverupdated", attributes=["virtualserver_welcomemessage", "virtualserver_maxclients", "virtualserver_clientsonline", "virtualserver_channelsonline", "virtualserver_uptime", "virtualserver_hostmessage", "virtualserver_hostmessage_mode", "virtualserver_flag_password", "virtualserver_default_channel_admin_group", "virtualserver_max_download_total_bandwidth", "virtualserver_max_upload_total_bandwidth", "virtualserver_complain_autoban_count", "virtualserver_complain_autoban_time", "virtualserver_complain_remove_time", "virtualserver_min_clients_in_channel_before_forced_silence", "virtualserver_antiflood_points_tick_reduce", "virtualserver_antiflood_points_needed_command_block", "virtualserver_antiflood_points_needed_ip_block", "virtualserver_client_connections", "virtualserver_query_client_connections", "virtualserver_queryclientsonline", "virtualserver_download_quota", "virtualserver_upload_quota", "virtualserver_month_bytes_downloaded", "virtualserver_month_bytes_uploaded", "virtualserver_total_bytes_downloaded", "virtualserver_total_bytes_uploaded", "virtualserver_port", "virtualserver_autostart", "virtualserver_machine_id", "virtualserver_needed_identity_security_level", "virtualserver_log_client", "virtualserver_log_query", "virtualserver_log_channel", "virtualserver_log_permissions", "virtualserver_log_server", "virtualserver_log_filetransfer", "virtualserver_min_client_version", "virtualserver_reserved_slots", "virtualserver_total_packetloss_speech", "virtualserver_total_packetloss_keepalive", "virtualserver_total_packetloss_control", "virtualserver_total_packetloss_total", "virtualserver_total_ping", "virtualserver_weblist_enabled", "virtualserver_min_android_version", "virtualserver_min_ios_version", "virtualserver_antiflood_points_needed_plugin_block"] },
{ name="TokenUsed", notify="notifytokenused", attributes=["token", "tokencustomset", "token1", "token2", "clid", "cldbid", "cluid"] },
# TeamSpeak 6 streams. Only StreamStarted is confirmed; the others are
# reported by reverse engineering, so most attributes are optional.
# notifystreamstarted clid=20 id=e7da957e-7ce0-46cf-bf6d-754d3446b4d4 name=probe type=3 access=1 mode=1 bitrate=4608 viewer_limit=0 audio=1
{ name="StreamStarted", notify="notifystreamstarted", attributes=["clid", "id@stream", "name@stream?", "type@stream?", "access@stream?", "mode@stream?", "bitrate@stream?", "viewer_limit@stream?", "audio@stream?", "return_code?"] },
{ name="StreamStopped", notify="notifystreamstopped", attributes=["id@stream", "clid?"] },
{ name="StreamInfo", notify="notifystreaminfo", attributes=["id@stream", "clid?", "name@stream?", "type@stream?", "access@stream?", "mode@stream?", "bitrate@stream?", "viewer_limit@stream?", "audio@stream?"] },
{ name="JoinStreamRequest", notify="notifyjoinstreamrequest", attributes=["id@stream", "clid", "msg?"] },
{ name="RespondJoinStreamRequest", notify="notifyrespondjoinstreamrequest", attributes=["id@stream", "clid?", "msg?", "offer@stream?", "decision@stream?"] },
{ name="StreamSignaling", notify="notifystreamsignaling", attributes=["id@stream", "clid", "json@stream"] },
{ name="StreamClientJoined", notify="notifystreamclientjoined", attributes=["id@stream", "clid"] },
{ name="StreamClientLeft", notify="notifystreamclientleft", attributes=["id@stream", "clid"] },
]
# Server to Client Notifications (Low)
@@ -1025,4 +1053,12 @@ msg = [
{ name="WhoAmIRequest", notify="whoami", attributes=[] },
# clientdisconnect reasonid=7 reasonmsg=Client\sdisconnected
{ name="Disconnect", notify="clientdisconnect", attributes=["reasonid?", "reasonmsg?"] },
# TeamSpeak 6 streams (see docs/protocol-notes/ts6-streaming.md)
# setupstream name=probe type=3 bitrate=4608 accessibility=1 mode=1 viewer_limit=0 audio=1
# -> {StreamStarted}
{ name="SetupStream", notify="setupstream", attributes=["name@stream", "type@stream", "bitrate@stream", "accessibility@stream", "mode@stream", "viewer_limit@stream", "audio@stream"] },
{ name="StopStream", notify="stopstream", attributes=["id@stream"] },
{ name="StreamSignalingRequest", notify="streamsignaling", attributes=["id@stream", "clid", "json@stream"] },
{ name="RespondJoinStreamRequestRequest", notify="respondjoinstreamrequest", attributes=["id@stream", "clid", "msg?", "offer@stream?", "decision@stream"] },
{ name="RemoveClientFromStream", notify="removeclientfromstream", attributes=["id@stream", "clid"] },
]
+5
View File
@@ -75,6 +75,11 @@ notifyclientupdated clid=20 client_is_streaming=1
notifystreamstarted clid=20 id=e7da957e-7ce0-46cf-bf6d-754d3446b4d4 name=probe type=3 access=1 mode=1 bitrate=4608 viewer_limit=0 audio=1 return_code=0
```
Other clients in the channel receive the same `notifystreamstarted` (without
`return_code`) and `notifyclientupdated clid=<streamer> client_is_streaming=1`;
`client_is_streaming` is also part of `notifycliententerview` and `initserver`.
When the streamer disconnects, everyone gets `notifystreamstopped id=<uuid>`.
Stream ids are UUIDs. The notification carries the command's `return_code`, and
the field is named `access` there (not `accessibility`).
+67 -6
View File
@@ -11,8 +11,8 @@ use tsclientlib::events::{Event, PropertyId, PropertyValue};
use tsclientlib::messages::c2s::{OutTokenUseMessage, OutTokenUsePart};
use tsclientlib::prelude::*;
use tsclientlib::{
ChannelId, ClientId, Connection, DisconnectOptions, MessageHandle, MessageTarget, StreamItem,
data,
ChannelId, ClientId, Connection, DisconnectOptions, InMessage, MessageHandle, MessageTarget,
StreamItem, data,
};
use tsproto_packets::packets::{Direction, Flags, OutCommand, PacketType};
@@ -238,10 +238,58 @@ fn describe(state: &data::Connection, event: &Event) -> Option<String> {
channel_name(state, client.channel)
))
}
Event::PropertyChanged { id: PropertyId::ClientIsStreaming(clid), .. } => {
let client = state.clients.get(clid)?;
let what = if client.is_streaming == Some(true) { "started" } else { "stopped" };
Some(format!("* {} (clid {}) {what} streaming", client.name, clid.0))
}
_ => None,
}
}
/// One line for TeamSpeak 6 stream notifications, `None` for other messages.
fn describe_message(msg: &InMessage) -> Option<String> {
let lines: Vec<String> = match msg {
InMessage::StreamStarted(m) => m
.iter()
.map(|p| {
format!(
"* stream {} started by clid {} (name {:?}, type {:?}, bitrate {:?}, audio {:?})",
p.stream_id,
p.client_id.0,
p.stream_name.as_deref().unwrap_or(""),
p.stream_type,
p.bitrate,
p.audio
)
})
.collect(),
InMessage::StreamStopped(m) => {
m.iter().map(|p| format!("* stream {} stopped", p.stream_id)).collect()
}
InMessage::JoinStreamRequest(m) => m
.iter()
.map(|p| format!("* clid {} asks to join stream {}", p.client_id.0, p.stream_id))
.collect(),
InMessage::StreamSignaling(m) => m
.iter()
.map(|p| {
format!("* signaling from clid {} on {}: {}", p.client_id.0, p.stream_id, p.json)
})
.collect(),
InMessage::StreamClientJoined(m) => m
.iter()
.map(|p| format!("* clid {} joined stream {}", p.client_id.0, p.stream_id))
.collect(),
InMessage::StreamClientLeft(m) => m
.iter()
.map(|p| format!("* clid {} left stream {}", p.client_id.0, p.stream_id))
.collect(),
_ => return None,
};
Some(lines.join("\n"))
}
/// Print book events; returns `true` if a text message contained `expect`.
fn print_events(
state: &data::Connection,
@@ -271,10 +319,18 @@ async fn listen(
) -> Result<()> {
let deadline = timeout.map(|t| Instant::now() + t);
let end = pump(con, deadline, |con, item| {
if let StreamItem::BookEvents(events) = item
&& print_events(con.get_state()?, &events, json, expect)?
{
return Ok(Flow::Stop);
match item {
StreamItem::BookEvents(events) => {
if print_events(con.get_state()?, &events, json, expect)? {
return Ok(Flow::Stop);
}
}
StreamItem::MessageEvent(msg) if !json => {
if let Some(line) = describe_message(&msg) {
println!("{line}");
}
}
_ => {}
}
Ok(Flow::Continue)
})
@@ -324,6 +380,11 @@ async fn repl(con: &mut Connection) -> Result<()> {
StreamItem::BookEvents(events) => {
print_events(con.get_state()?, &events, false, None)?;
}
StreamItem::MessageEvent(msg) => {
if let Some(line) = describe_message(&msg) {
println!("{line}");
}
}
StreamItem::MessageResult(handle, Err(error)) => {
println!("error (command {}): {error}", handle.0);
}
+8 -1
View File
@@ -25,6 +25,7 @@ pub struct ClientNode {
pub input_muted: bool,
pub output_muted: bool,
pub away: bool,
pub streaming: bool,
}
/// Sort siblings by following the `order` links (each channel names the
@@ -82,6 +83,9 @@ fn render_level(
if client.away {
flags.push("away");
}
if client.streaming {
flags.push("streaming");
}
let flags =
if flags.is_empty() { String::new() } else { format!(" [{}]", flags.join(", ")) };
let _ = writeln!(out, "{indent} - {}{flags}", client.name);
@@ -107,6 +111,7 @@ pub fn from_state(state: &data::Connection) -> String {
input_muted: c.input_muted,
output_muted: c.output_muted,
away: c.away_message.is_some(),
streaming: c.is_streaming == Some(true),
})
.collect();
render(&state.server.name, &channels, &clients)
@@ -134,6 +139,7 @@ mod tests {
input_muted: false,
output_muted: false,
away: false,
streaming: false,
}
}
@@ -161,6 +167,7 @@ mod tests {
query.is_query = true;
let mut muted = cl(3, "Bob", 0);
muted.input_muted = true;
muted.streaming = true;
let clients = [cl(1, "Alice", 10), cl(1, "Zed", 50), query, muted];
let text = render("Test Server", &channels, &clients);
assert_eq!(
@@ -171,7 +178,7 @@ mod tests {
- Alice\n\
# Games (cid 2)\n \
# Squad (cid 3)\n \
- Bob [mic off]\n"
- Bob [mic off, streaming]\n"
);
}
}