chore: clarify UDP on WASM

This commit is contained in:
kozabrada123 2023-12-30 11:42:44 +01:00
parent d08fe070d9
commit 0eca0f706c
4 changed files with 8 additions and 28 deletions

View File

@ -15,7 +15,7 @@ default = ["client", "rt-multi-thread"]
backend = ["dep:poem", "dep:sqlx"]
rt-multi-thread = ["tokio/rt-multi-thread"]
rt = ["tokio/rt"]
client = ["voice"]
client = []
voice = ["dep:discortp", "dep:crypto_secretbox"]
[dependencies]

View File

@ -128,7 +128,7 @@ pub mod instance;
#[cfg(feature = "client")]
pub mod ratelimiter;
pub mod types;
#[cfg(feature = "client")]
#[cfg(all(feature = "client", feature = "voice"))]
pub mod voice;
#[derive(Clone, Default, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]

View File

@ -1,19 +1,12 @@
#[cfg(all(not(target_arch = "wasm32"), feature = "client"))]
#[cfg(all(not(target_arch = "wasm32"), feature = "voice"))]
pub mod tokio;
#[cfg(all(not(target_arch = "wasm32"), feature = "client"))]
#[cfg(all(not(target_arch = "wasm32"), feature = "voice"))]
pub use tokio::*;
#[cfg(all(target_arch = "wasm32", feature = "client"))]
pub mod wasm;
#[cfg(all(target_arch = "wasm32", feature = "client"))]
pub use wasm::*;
#[cfg(all(not(target_arch = "wasm32"), feature = "client"))]
#[cfg(all(not(target_arch = "wasm32"), feature = "voice"))]
pub type UdpSocket = tokio::TokioSocket;
#[cfg(all(not(target_arch = "wasm32"), feature = "client"))]
#[cfg(all(not(target_arch = "wasm32"), feature = "voice"))]
pub type UdpBackend = tokio::TokioBackend;
#[cfg(all(target_arch = "wasm32", feature = "client"))]
pub type UdpSocket = wasm::WasmSocket;
#[cfg(all(target_arch = "wasm32", feature = "client"))]
pub type UdpBackend = wasm::WasmBackend;
#[cfg(target_arch = "wasm32")]
compile_error!("UDP Voice support is not (and will likely never be) supported for WASM. This is because UDP cannot be used in the browser. We are however looking into Webrtc for WASM voice support.");

View File

@ -1,13 +0,0 @@
use std::net::SocketAddr;
// TODO: Add wasm websockets
compile_error!("Udp voice support is not implemented yet for wasm.");
#[derive(Debug, Clone)]
pub struct WasmBackend;
pub type WasmSocket;
impl WasmBackend {
pub async fn connect(url: SocketAddr) -> Result<WasmSocket, VoiceUdpError> {}
}