Compare commits
2 Commits
011b66423a
...
326b9eee63
| Author | SHA1 | Date | |
|---|---|---|---|
| 326b9eee63 | |||
| 6c808694db |
+2
-2
@@ -26,12 +26,12 @@ ogg = "0.9.1"
|
||||
ordermap = "0.5.3"
|
||||
html-purifier = "0.3.0"
|
||||
markdown = "0.3.0"
|
||||
gloo-timers = { version = "0.3.0", features = ["futures"] }
|
||||
gloo-timers = { version = "0.3.0", features = ["futures"], optional = true }
|
||||
futures-channel = "0.3.30"
|
||||
sir = { version = "0.5.0", features = ["dioxus"] }
|
||||
tokio = { version = "1.41.1", features = ["net", "rt"], optional = true }
|
||||
tokio-rustls = { version = "0.26.0", optional = true }
|
||||
|
||||
[features]
|
||||
web = ["dioxus/web", "dioxus-web", "wasm-bindgen", "wasm-bindgen-futures", "wasm-streams", "serde-wasm-bindgen", "js-sys", "web-sys"]
|
||||
web = ["dioxus/web", "dioxus-web", "wasm-bindgen", "wasm-bindgen-futures", "wasm-streams", "serde-wasm-bindgen", "js-sys", "web-sys", "gloo-timers"]
|
||||
desktop = ["dioxus/desktop", "tokio", "tokio-rustls"]
|
||||
|
||||
+62
-4
@@ -20,12 +20,21 @@ pub enum Command {
|
||||
Connect {
|
||||
address: String,
|
||||
username: String,
|
||||
hash: String,
|
||||
},
|
||||
SendChat {
|
||||
markdown: String,
|
||||
channels: Vec<ChannelId>,
|
||||
},
|
||||
SetMute {
|
||||
mute: bool,
|
||||
},
|
||||
SetDeaf {
|
||||
deaf: bool,
|
||||
},
|
||||
EnterChannel {
|
||||
channel: ChannelId,
|
||||
user: UserId,
|
||||
},
|
||||
Disconnect,
|
||||
}
|
||||
|
||||
@@ -44,6 +53,10 @@ pub struct ChannelState {
|
||||
pub struct UserState {
|
||||
pub name: String,
|
||||
pub channel: ChannelId,
|
||||
pub deaf: bool,
|
||||
pub mute: bool,
|
||||
pub self_deaf: bool,
|
||||
pub self_mute: bool,
|
||||
}
|
||||
|
||||
pub struct Chat {
|
||||
@@ -106,7 +119,9 @@ pub fn User(id: UserId) -> Element {
|
||||
|
||||
#[component]
|
||||
pub fn Channel(id: ChannelId) -> Element {
|
||||
let net: Coroutine<Command> = use_coroutine_handle();
|
||||
let server = STATE.server.read();
|
||||
let user = server.session?;
|
||||
let state = server.channels.get(&id)?;
|
||||
|
||||
let channel_details = css!(
|
||||
@@ -130,7 +145,10 @@ pub fn Channel(id: ChannelId) -> Element {
|
||||
details {
|
||||
class: "{channel_details}",
|
||||
open: true,
|
||||
summary { "{state.name}" }
|
||||
summary {
|
||||
ondoubleclick: move |_| net.send(EnterChannel { channel: id, user }),
|
||||
"{state.name}"
|
||||
}
|
||||
div {
|
||||
class: "{channel_children}",
|
||||
for id in state.users.iter() {
|
||||
@@ -230,6 +248,13 @@ pub fn ChatView() -> Element {
|
||||
pub fn ServerView() -> Element {
|
||||
let net: Coroutine<Command> = use_coroutine_handle();
|
||||
let server = STATE.server.read();
|
||||
let &UserState {
|
||||
deaf,
|
||||
self_deaf,
|
||||
mute,
|
||||
self_mute,
|
||||
..
|
||||
} = server.this_user()?;
|
||||
|
||||
let grid = css!(
|
||||
r#"
|
||||
@@ -281,6 +306,11 @@ pub fn ServerView() -> Element {
|
||||
border: solid black 1px;
|
||||
grid-area: bar;
|
||||
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
gap: 16px;
|
||||
align-items: center;
|
||||
|
||||
button {
|
||||
padding: 8px;
|
||||
}
|
||||
@@ -296,7 +326,32 @@ pub fn ServerView() -> Element {
|
||||
onclick: move |_| net.send(Disconnect),
|
||||
"Disconnect"
|
||||
}
|
||||
|
||||
span {
|
||||
input {
|
||||
r#type: "checkbox",
|
||||
id: "mute",
|
||||
checked: mute || self_mute,
|
||||
disabled: mute,
|
||||
onchange: move |_| net.send(SetMute { mute: !self_mute }),
|
||||
}
|
||||
label {
|
||||
r#for: "mute",
|
||||
"Mute"
|
||||
}
|
||||
}
|
||||
span {
|
||||
input {
|
||||
r#type: "checkbox",
|
||||
id: "deaf",
|
||||
checked: deaf || self_deaf,
|
||||
disabled: deaf,
|
||||
onchange: move |_| net.send(SetDeaf { deaf: !self_deaf }),
|
||||
}
|
||||
label {
|
||||
r#for: "deaf",
|
||||
"Deafen"
|
||||
}
|
||||
}
|
||||
}
|
||||
div {
|
||||
class: "{channel_box}",
|
||||
@@ -348,7 +403,10 @@ pub fn LoginView() -> Element {
|
||||
);
|
||||
|
||||
let do_connect = move |_| {
|
||||
net.send(Connect{address: address.read().clone(), username: username.read().clone(), hash: "[39, 96, 204, 127, 26, 59, 35, 209, 197, 103, 192, 6, 3, 98, 203, 228, 124, 46, 247, 72, 44, 224, 123, 238, 218, 140, 128, 100, 115, 14, 23, 233]".to_string()})
|
||||
net.send(Connect {
|
||||
address: address.read().clone(),
|
||||
username: username.read().clone(),
|
||||
})
|
||||
};
|
||||
let status = &STATE.status;
|
||||
let bottom = match &*status.read() {
|
||||
|
||||
+3
-3
@@ -67,12 +67,12 @@ pub struct AudioSystem();
|
||||
|
||||
impl AudioSystem {
|
||||
pub fn new(sender: UnboundedSender<ControlPacket<Serverbound>>) -> Result<Self, Error> {
|
||||
dbg!("todo");
|
||||
// dbg!("todo");
|
||||
Ok(AudioSystem())
|
||||
}
|
||||
|
||||
pub fn create_player(&mut self) -> Result<AudioPlayer, Error> {
|
||||
dbg!("todo");
|
||||
// dbg!("todo");
|
||||
Ok(AudioPlayer())
|
||||
}
|
||||
}
|
||||
@@ -81,7 +81,7 @@ pub struct AudioPlayer();
|
||||
|
||||
impl AudioPlayer {
|
||||
pub fn play_opus(&mut self, payload: &[u8]) {
|
||||
dbg!("todo");
|
||||
// dbg!("todo");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+38
-8
@@ -41,12 +41,7 @@ macro_rules! bail {
|
||||
|
||||
pub async fn network_entrypoint(mut event_rx: UnboundedReceiver<Command>) {
|
||||
loop {
|
||||
let Some(Command::Connect {
|
||||
address,
|
||||
username,
|
||||
hash,
|
||||
}) = event_rx.next().await
|
||||
else {
|
||||
let Some(Command::Connect { address, username }) = event_rx.next().await else {
|
||||
panic!("Did not receive connect command")
|
||||
};
|
||||
|
||||
@@ -169,8 +164,13 @@ fn accept_command(
|
||||
command: Command,
|
||||
send_chan: &mut UnboundedSender<ControlPacket<mumble_protocol::Serverbound>>,
|
||||
) -> Result<(), Error> {
|
||||
use Command::*;
|
||||
let Some(session) = STATE.server.read().session else {
|
||||
bail!("no session id")
|
||||
};
|
||||
|
||||
match command {
|
||||
Command::SendChat { markdown, channels } => {
|
||||
SendChat { markdown, channels } => {
|
||||
use markdown::*;
|
||||
let blocks = tokenize(&markdown);
|
||||
let html_text = match blocks.as_slice() {
|
||||
@@ -204,7 +204,25 @@ fn accept_command(
|
||||
u.set_channel_id(channels);
|
||||
let _ = send_chan.unbounded_send(u.into());
|
||||
}
|
||||
_ => (),
|
||||
SetMute { mute } => {
|
||||
let mut u = msgs::UserState::new();
|
||||
u.set_session(session);
|
||||
u.set_self_mute(mute);
|
||||
let _ = send_chan.unbounded_send(u.into());
|
||||
}
|
||||
SetDeaf { deaf } => {
|
||||
let mut u = msgs::UserState::new();
|
||||
u.set_session(session);
|
||||
u.set_self_deaf(deaf);
|
||||
let _ = send_chan.unbounded_send(u.into());
|
||||
}
|
||||
EnterChannel { channel, user } => {
|
||||
let mut u = msgs::UserState::new();
|
||||
u.set_session(user);
|
||||
u.set_channel_id(channel);
|
||||
let _ = send_chan.unbounded_send(u.into());
|
||||
}
|
||||
Connect { .. } | Disconnect => (),
|
||||
}
|
||||
|
||||
Ok(())
|
||||
@@ -311,6 +329,18 @@ fn accept_packet(
|
||||
if u.has_name() {
|
||||
state.name = u.get_name().to_string();
|
||||
}
|
||||
if u.has_mute() {
|
||||
state.mute = u.get_mute();
|
||||
}
|
||||
if u.has_deaf() {
|
||||
state.deaf = u.get_deaf();
|
||||
}
|
||||
if u.has_self_mute() {
|
||||
state.self_mute = u.get_self_mute();
|
||||
}
|
||||
if u.has_self_deaf() {
|
||||
state.self_deaf = u.get_self_deaf();
|
||||
}
|
||||
}
|
||||
ControlPacket::UserRemove(u) => {
|
||||
let mut server = STATE.server.write();
|
||||
|
||||
Reference in New Issue
Block a user