desktop and web working

This commit is contained in:
2024-11-08 18:18:08 -07:00
parent 86fc23b3cb
commit 011b66423a
4 changed files with 20 additions and 19 deletions
Generated
+1 -1
View File
@@ -1,6 +1,6 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 4
version = 3
[[package]]
name = "addr2line"
+8 -4
View File
@@ -1,6 +1,7 @@
use crate::app::Command;
use anyhow::Result;
use dioxus::hooks::{UnboundedReceiver, UnboundedSender};
use futures::io::{AsyncRead, AsyncWrite};
use mumble_protocol::control::{ClientControlCodec, ControlPacket};
use mumble_protocol::Serverbound;
use std::net::ToSocketAddrs;
@@ -15,11 +16,17 @@ use tokio_rustls::rustls::DigitallySignedStruct;
use tokio_rustls::TlsConnector;
use tokio_util::compat::{TokioAsyncReadCompatExt as _, TokioAsyncWriteCompatExt as _};
pub use tokio::task::spawn_local as spawn;
pub use tokio::task::spawn;
pub use tokio::time::sleep;
pub struct Error(anyhow::Error);
pub trait ImpRead: AsyncRead + Unpin + Send + 'static {}
impl<T: AsyncRead + Unpin + Send + 'static> ImpRead for T {}
pub trait ImpWrite: AsyncWrite + Unpin + Send + 'static {}
impl<T: AsyncWrite + Unpin + Send + 'static> ImpWrite for T {}
impl From<anyhow::Error> for Error {
fn from(value: anyhow::Error) -> Self {
Error(value)
@@ -135,9 +142,6 @@ pub async fn network_connect(
username: String,
event_rx: &mut UnboundedReceiver<Command>,
) -> Result<(), Error> {
let localset = LocalSet::new();
let _guard = localset.enter();
let config = ClientConfig::builder()
.dangerous()
.with_custom_certificate_verifier(Arc::new(NoCertificateVerification))
+8
View File
@@ -1,6 +1,8 @@
use crate::app::Command;
use crate::bail;
use dioxus::prelude::*;
use futures::AsyncRead;
use futures::AsyncWrite;
use futures_channel::mpsc::UnboundedSender;
use gloo_timers::future::TimeoutFuture;
use mumble_protocol::control::ClientControlCodec;
@@ -43,6 +45,12 @@ use web_sys::WorkletOptions;
pub use wasm_bindgen_futures::spawn_local as spawn;
pub trait ImpRead: AsyncRead + Unpin + 'static {}
impl<T: AsyncRead + Unpin + 'static> ImpRead for T {}
pub trait ImpWrite: AsyncWrite + Unpin + 'static {}
impl<T: AsyncWrite + Unpin + 'static> ImpWrite for T {}
pub async fn sleep(d: Duration) {
TimeoutFuture::new(d.as_millis() as u32).await
}
+3 -14
View File
@@ -5,14 +5,10 @@ use app::STATE;
use asynchronous_codec::FramedRead;
use asynchronous_codec::FramedWrite;
use dioxus::prelude::*;
use futures::io::AsyncRead;
use futures::io::AsyncWrite;
use futures::select;
use futures::FutureExt as _;
use futures::Sink;
use futures::SinkExt as _;
use futures::Stream;
use futures::StreamExt;
use futures::StreamExt as _;
use futures_channel::mpsc::UnboundedSender;
pub use imp::spawn;
pub use imp::Error;
@@ -24,9 +20,6 @@ use mumble_protocol::Clientbound;
use mumble_protocol::Serverbound;
use std::collections::hash_map::Entry;
use std::collections::HashMap;
use std::future::Future;
use std::io;
use std::pin::Pin;
use std::time::Duration;
pub mod app;
@@ -68,16 +61,12 @@ pub async fn network_entrypoint(mut event_rx: UnboundedReceiver<Command>) {
}
}
pub async fn network_loop<R, W>(
pub async fn network_loop<R: imp::ImpRead, W: imp::ImpWrite>(
username: String,
event_rx: &mut UnboundedReceiver<Command>,
mut reader: FramedRead<R, ControlCodec<Serverbound, Clientbound>>,
mut writer: FramedWrite<W, ControlCodec<Serverbound, Clientbound>>,
) -> Result<(), Error>
where
R: AsyncRead + Unpin + 'static,
W: AsyncWrite + Unpin + 'static,
{
) -> Result<(), Error> {
let (mut send_chan, mut writer_recv_chan) = futures_channel::mpsc::unbounded();
spawn(async move {
while let Some(msg) = writer_recv_chan.next().await {