feat: stabilize voice activity and audio routing
This commit is contained in:
@@ -659,17 +659,11 @@ async fn connection_task(
|
||||
..
|
||||
} = &ev
|
||||
{
|
||||
let own_client = con
|
||||
.get_state()
|
||||
.ok()
|
||||
.map(|state| state.own_client);
|
||||
let own_client = con.get_state().ok().map(|state| state.own_client);
|
||||
if own_client == Some(*client_id) {
|
||||
let current_channel = con
|
||||
.get_state()
|
||||
.ok()
|
||||
.and_then(|state| {
|
||||
state.clients.get(client_id).map(|client| client.channel.0)
|
||||
});
|
||||
let current_channel = con.get_state().ok().and_then(|state| {
|
||||
state.clients.get(client_id).map(|client| client.channel.0)
|
||||
});
|
||||
if let Some(current_channel) = current_channel {
|
||||
let matched: Vec<MessageHandle> = pending_moves
|
||||
.iter()
|
||||
@@ -682,7 +676,9 @@ async fn connection_task(
|
||||
})
|
||||
.collect();
|
||||
for handle in matched {
|
||||
if let Some((_, reply, _)) = pending_moves.remove(&handle) {
|
||||
if let Some((_, reply, _)) =
|
||||
pending_moves.remove(&handle)
|
||||
{
|
||||
info!(
|
||||
target: "chanora_protocol",
|
||||
channel_id = current_channel,
|
||||
@@ -727,7 +723,9 @@ async fn connection_task(
|
||||
}
|
||||
}
|
||||
StreamItem::MessageResult(handle, result) => {
|
||||
if let Some((_target_channel, reply, _deadline)) = pending_moves.remove(&handle) {
|
||||
if let Some((_target_channel, reply, _deadline)) =
|
||||
pending_moves.remove(&handle)
|
||||
{
|
||||
let mapped = match result {
|
||||
Ok(()) => Ok(()),
|
||||
Err(cmd_err) => {
|
||||
@@ -814,36 +812,32 @@ async fn connection_task(
|
||||
channel_id,
|
||||
password,
|
||||
reply,
|
||||
}) => {
|
||||
match move_self_to(&mut con, channel_id, password.as_deref()) {
|
||||
Ok(handle) => {
|
||||
let deadline = std::time::Instant::now() + Duration::from_secs(3);
|
||||
pending_moves.insert(handle, (channel_id, Some(reply), deadline));
|
||||
}
|
||||
Err(e) => {
|
||||
let _ = reply.send(Err(e));
|
||||
}
|
||||
}) => match move_self_to(&mut con, channel_id, password.as_deref()) {
|
||||
Ok(handle) => {
|
||||
let deadline = std::time::Instant::now() + Duration::from_secs(3);
|
||||
pending_moves.insert(handle, (channel_id, Some(reply), deadline));
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
let _ = reply.send(Err(e));
|
||||
}
|
||||
},
|
||||
Ok(Request::MoveToChannelNoWait {
|
||||
channel_id,
|
||||
password,
|
||||
}) => {
|
||||
match move_self_to(&mut con, channel_id, password.as_deref()) {
|
||||
Ok(handle) => {
|
||||
let deadline = std::time::Instant::now() + Duration::from_secs(3);
|
||||
pending_moves.insert(handle, (channel_id, None, deadline));
|
||||
}
|
||||
Err(e) => {
|
||||
warn!(
|
||||
target: "chanora_protocol",
|
||||
error = %e,
|
||||
channel_id,
|
||||
"fire-and-forget client_move could not be queued"
|
||||
);
|
||||
}
|
||||
}) => match move_self_to(&mut con, channel_id, password.as_deref()) {
|
||||
Ok(handle) => {
|
||||
let deadline = std::time::Instant::now() + Duration::from_secs(3);
|
||||
pending_moves.insert(handle, (channel_id, None, deadline));
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
warn!(
|
||||
target: "chanora_protocol",
|
||||
error = %e,
|
||||
channel_id,
|
||||
"fire-and-forget client_move could not be queued"
|
||||
);
|
||||
}
|
||||
},
|
||||
Ok(Request::SetMuted {
|
||||
input,
|
||||
output,
|
||||
@@ -1261,10 +1255,7 @@ fn activity_channel_group_name(
|
||||
.map(|group| quoted(&group.name))
|
||||
}
|
||||
|
||||
fn activity_server_group_name(
|
||||
con: &Connection,
|
||||
id: tsclientlib::ServerGroupId,
|
||||
) -> Option<String> {
|
||||
fn activity_server_group_name(con: &Connection, id: tsclientlib::ServerGroupId) -> Option<String> {
|
||||
con.get_state()
|
||||
.ok()
|
||||
.and_then(|state| state.server_groups.get(&id))
|
||||
@@ -1282,7 +1273,11 @@ fn format_server_activity(con: &Connection, ev: &tsclientlib::events::Event) ->
|
||||
use tsproto_types::Reason;
|
||||
|
||||
match ev {
|
||||
Event::PropertyAdded { id: PropertyId::Client(client_id), extra, .. } => {
|
||||
Event::PropertyAdded {
|
||||
id: PropertyId::Client(client_id),
|
||||
extra,
|
||||
..
|
||||
} => {
|
||||
if extra.reason.is_none() {
|
||||
return None;
|
||||
}
|
||||
@@ -1294,7 +1289,12 @@ fn format_server_activity(con: &Connection, ev: &tsclientlib::events::Event) ->
|
||||
channel
|
||||
))
|
||||
}
|
||||
Event::PropertyRemoved { id: PropertyId::Client(_), old, extra, .. } => {
|
||||
Event::PropertyRemoved {
|
||||
id: PropertyId::Client(_),
|
||||
old,
|
||||
extra,
|
||||
..
|
||||
} => {
|
||||
let PropertyValue::Client(client) = old else {
|
||||
return None;
|
||||
};
|
||||
@@ -1305,12 +1305,9 @@ fn format_server_activity(con: &Connection, ev: &tsclientlib::events::Event) ->
|
||||
Some(Reason::Clientdisconnect) => {
|
||||
Some(format!("{} disconnected (Leaving)", quoted(&client.name)))
|
||||
}
|
||||
Some(Reason::ClientdisconnectServerShutdown) | Some(Reason::Serverstop) => {
|
||||
Some(format!(
|
||||
"{} disconnected (server shutdown)",
|
||||
quoted(&client.name)
|
||||
))
|
||||
}
|
||||
Some(Reason::ClientdisconnectServerShutdown) | Some(Reason::Serverstop) => Some(
|
||||
format!("{} disconnected (server shutdown)", quoted(&client.name)),
|
||||
),
|
||||
_ => Some(format!(
|
||||
"{} dropped (connection lost)",
|
||||
quoted(&client.name)
|
||||
@@ -1329,8 +1326,7 @@ fn format_server_activity(con: &Connection, ev: &tsclientlib::events::Event) ->
|
||||
let client = activity_client(con, *client_id)?;
|
||||
let from = activity_channel_name(con, *from_channel_id)?;
|
||||
let to = activity_channel_name(con, client.channel)?;
|
||||
if invoker.as_ref().map(|invoker| invoker.id) == Some(*client_id) || invoker.is_none()
|
||||
{
|
||||
if invoker.as_ref().map(|invoker| invoker.id) == Some(*client_id) || invoker.is_none() {
|
||||
Some(format!(
|
||||
"{} switched from channel {} to {}",
|
||||
quoted(&client.name),
|
||||
|
||||
Reference in New Issue
Block a user