feat(client): protocol v2 wire layer, screen sharing, channel webhooks and secure voice
Verified against the real gateway via tests/gateway_interop.rs.
This commit is contained in:
parent
8460fb28fd
commit
3d7dd5413b
65 changed files with 6048 additions and 1156 deletions
|
|
@ -19,7 +19,7 @@ pub async fn net_task(
|
|||
let mut target: Option<SessionTarget> = None;
|
||||
let mut failures: u32 = 0;
|
||||
|
||||
loop {
|
||||
'session: loop {
|
||||
let Some(mut session) = target.take() else {
|
||||
match wait_for_connect(&mut cmd_rx).await {
|
||||
Some(t) => {
|
||||
|
|
@ -39,7 +39,26 @@ pub async fn net_task(
|
|||
delay_secs: delay.as_secs(),
|
||||
})
|
||||
.await;
|
||||
sleep(delay).await;
|
||||
let delay = sleep(delay);
|
||||
tokio::pin!(delay);
|
||||
loop {
|
||||
tokio::select! {
|
||||
_ = &mut delay => break,
|
||||
command = cmd_rx.recv() => match command {
|
||||
Some(NetCommand::Connect {address,auto_reconnect}) => {
|
||||
session.address=address;session.auto_reconnect=auto_reconnect;
|
||||
failures=0;target=Some(session);continue 'session;
|
||||
}
|
||||
Some(NetCommand::Disconnect) => {
|
||||
failures=0;
|
||||
let _=event_tx.send(NetEvent::Disconnected {reason:"disconnected".into(),will_retry:false}).await;
|
||||
continue 'session;
|
||||
}
|
||||
None => return,
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
info!(
|
||||
|
|
@ -109,8 +128,30 @@ async fn wait_for_connect(cmd_rx: &mut mpsc::Receiver<NetCommand>) -> Option<Ses
|
|||
channels: vec!["general".into()],
|
||||
});
|
||||
}
|
||||
Some(NetCommand::Disconnect) | None => return None,
|
||||
None => return None,
|
||||
Some(NetCommand::Disconnect) => continue,
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
#[tokio::test]
|
||||
async fn disconnected_cancel_does_not_disable_later_connections() {
|
||||
let (sender, mut receiver) = mpsc::channel(4);
|
||||
sender.send(NetCommand::Disconnect).await.unwrap();
|
||||
sender
|
||||
.send(NetCommand::Connect {
|
||||
address: "127.0.0.1:7600".into(),
|
||||
auto_reconnect: false,
|
||||
})
|
||||
.await
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
wait_for_connect(&mut receiver).await.unwrap().address,
|
||||
"127.0.0.1:7600"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue