forked from lavina/lavina
1
0
Fork 0

fix some warnings

This commit is contained in:
Nikita Vilunov 2023-03-21 22:50:40 +01:00
parent 71d7323534
commit bba1ea107d
2 changed files with 14 additions and 20 deletions

View File

@ -112,9 +112,8 @@ impl PlayerHandle {
pub async fn subscribe(&self) -> PlayerConnection { pub async fn subscribe(&self) -> PlayerConnection {
let (sender, receiver) = channel(32); let (sender, receiver) = channel(32);
let (promise, deferred) = oneshot(); let (promise, deferred) = oneshot();
self.tx let cmd = PlayerCommand::AddConnection { sender, promise };
.send(PlayerCommand::AddConnection { sender, promise }) let _ = self.tx.send(cmd).await;
.await;
let connection_id = deferred.await.unwrap(); let connection_id = deferred.await.unwrap();
PlayerConnection { PlayerConnection {
connection_id, connection_id,
@ -135,7 +134,7 @@ impl PlayerHandle {
body, body,
promise, promise,
}; };
self.tx.send(PlayerCommand::Cmd(cmd, connection_id)).await; let _ = self.tx.send(PlayerCommand::Cmd(cmd, connection_id)).await;
Ok(deferred.await?) Ok(deferred.await?)
} }
@ -145,16 +144,13 @@ impl PlayerHandle {
connection_id: ConnectionId, connection_id: ConnectionId,
) -> Result<JoinResult> { ) -> Result<JoinResult> {
let (promise, deferred) = oneshot(); let (promise, deferred) = oneshot();
let cmd = Cmd::JoinRoom { let cmd = Cmd::JoinRoom { room_id, promise };
room_id, let _ = self.tx.send(PlayerCommand::Cmd(cmd, connection_id)).await;
promise: promise,
};
self.tx.send(PlayerCommand::Cmd(cmd, connection_id)).await;
Ok(deferred.await?) Ok(deferred.await?)
} }
async fn send(&self, command: PlayerCommand) { async fn send(&self, command: PlayerCommand) {
self.tx.send(command).await; let _ = self.tx.send(command).await;
} }
pub async fn update(&self, update: Updates) { pub async fn update(&self, update: Updates) {
@ -316,7 +312,7 @@ impl Player {
for (_, handle) in &self.my_rooms { for (_, handle) in &self.my_rooms {
response.push(handle.get_room_info().await); response.push(handle.get_room_info().await);
} }
promise.send(response); let _ = promise.send(response);
} }
PlayerCommand::Update(update) => { PlayerCommand::Update(update) => {
log::info!( log::info!(
@ -331,7 +327,7 @@ impl Player {
_ => {} _ => {}
} }
for (_, connection) in &self.connections { for (_, connection) in &self.connections {
connection.send(update.clone()).await; let _ = connection.send(update.clone()).await;
} }
} }
PlayerCommand::Cmd(cmd, connection_id) => self.handle_cmd(cmd, connection_id).await, PlayerCommand::Cmd(cmd, connection_id) => self.handle_cmd(cmd, connection_id).await,
@ -350,7 +346,7 @@ impl Player {
match cmd { match cmd {
Cmd::JoinRoom { room_id, promise } => { Cmd::JoinRoom { room_id, promise } => {
if self.banned_from.contains(&room_id) { if self.banned_from.contains(&room_id) {
promise.send(JoinResult::Banned); let _ = promise.send(JoinResult::Banned);
return; return;
} }
@ -359,7 +355,7 @@ impl Player {
.await; .await;
self.my_rooms.insert(room_id.clone(), room.clone()); self.my_rooms.insert(room_id.clone(), room.clone());
let room_info = room.get_room_info().await; let room_info = room.get_room_info().await;
promise.send(JoinResult::Success(room_info)); let _ = promise.send(JoinResult::Success(room_info));
let update = Updates::RoomJoined { let update = Updates::RoomJoined {
room_id, room_id,
new_member_id: self.player_id.clone(), new_member_id: self.player_id.clone(),
@ -372,7 +368,7 @@ impl Player {
room.unsubscribe(&self.player_id).await; room.unsubscribe(&self.player_id).await;
let room_info = room.get_room_info().await; let room_info = room.get_room_info().await;
} }
promise.send(()); let _ = promise.send(());
let update = Updates::RoomLeft { let update = Updates::RoomLeft {
room_id, room_id,
former_member_id: self.player_id.clone(), former_member_id: self.player_id.clone(),
@ -391,7 +387,7 @@ impl Player {
} else { } else {
tracing::info!("no room found"); tracing::info!("no room found");
} }
promise.send(()); let _ = promise.send(());
let update = Updates::NewMessage { let update = Updates::NewMessage {
room_id, room_id,
author_id: self.player_id.clone(), author_id: self.player_id.clone(),
@ -411,7 +407,7 @@ impl Player {
} else { } else {
tracing::info!("no room found"); tracing::info!("no room found");
} }
promise.send(()); let _ = promise.send(());
let update = Updates::RoomTopicChanged { room_id, new_topic }; let update = Updates::RoomTopicChanged { room_id, new_topic };
self.broadcast_update(update, connection_id).await; self.broadcast_update(update, connection_id).await;
} }
@ -423,7 +419,7 @@ impl Player {
if ConnectionId(a) == except { if ConnectionId(a) == except {
continue; continue;
} }
b.send(update.clone()).await; let _ = b.send(update.clone()).await;
} }
} }
} }

View File

@ -4,10 +4,8 @@ use quick_xml::name::{Namespace, QName, ResolveResult};
use quick_xml::{NsReader, Writer}; use quick_xml::{NsReader, Writer};
use tokio::io::{AsyncBufRead, AsyncWrite}; use tokio::io::{AsyncBufRead, AsyncWrite};
use super::client::Message;
use super::skip_text; use super::skip_text;
use crate::prelude::*; use crate::prelude::*;
use crate::util::xml::{Continuation, FromXml, Parser};
pub static XMLNS: &'static str = "http://etherx.jabber.org/streams"; pub static XMLNS: &'static str = "http://etherx.jabber.org/streams";
pub static PREFIX: &'static str = "stream"; pub static PREFIX: &'static str = "stream";