Broadcasting
This commit is contained in:
+16
-4
@@ -1,5 +1,6 @@
|
|||||||
|
use pulse_wire::PulseWire;
|
||||||
use tokio::{
|
use tokio::{
|
||||||
io::AsyncReadExt,
|
io::{AsyncReadExt, AsyncWriteExt},
|
||||||
net::{
|
net::{
|
||||||
UnixListener,
|
UnixListener,
|
||||||
unix::{OwnedReadHalf, OwnedWriteHalf},
|
unix::{OwnedReadHalf, OwnedWriteHalf},
|
||||||
@@ -65,8 +66,19 @@ impl TerminalServer {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn broadcast(&mut self) -> tokio::io::Result<()> {
|
pub async fn broadcast(
|
||||||
// for client in &mut self.clients {}
|
&mut self,
|
||||||
Ok(())
|
message: pulse_wire::terminal::TerminalServerMessage,
|
||||||
|
) -> tokio::io::Result<()> {
|
||||||
|
let mut res = Ok(());
|
||||||
|
let msg = message.to_com();
|
||||||
|
|
||||||
|
for client in &mut self.clients {
|
||||||
|
if let Err(e) = client.write(&msg).await {
|
||||||
|
res = Err(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
res
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user