forked from lavina/lavina
1
0
Fork 0

make PlayerCommand mod-private

This commit is contained in:
Nikita Vilunov 2023-02-15 21:49:52 +01:00
parent 8b4e963d39
commit 1e17e017cf
2 changed files with 7 additions and 7 deletions

View File

@ -89,8 +89,10 @@ impl PlayerConnection {
.await;
}
pub async fn send(&self, command: PlayerCommand) {
self.player_handle.send(command).await;
pub async fn get_rooms(&self) -> Result<Vec<RoomInfo>> {
let (promise, deferred) = oneshot();
self.player_handle.send(PlayerCommand::GetRooms(promise)).await;
Ok(deferred.await?)
}
}
@ -153,7 +155,7 @@ impl PlayerHandle {
}
}
pub enum PlayerCommand {
enum PlayerCommand {
/** Commands from connections */
AddConnection {
sender: Sender<Updates>,

View File

@ -7,7 +7,7 @@ use tokio::net::tcp::{ReadHalf, WriteHalf};
use tokio::net::{TcpListener, TcpStream};
use tokio::sync::oneshot::channel;
use crate::core::player::{PlayerCommand, PlayerConnection, PlayerId, PlayerRegistry, Updates};
use crate::core::player::{PlayerConnection, PlayerId, PlayerRegistry, Updates};
use crate::core::room::{RoomId, RoomInfo, RoomRegistry};
use crate::prelude::*;
use crate::protos::irc::client::{client_message, ClientMessage};
@ -196,9 +196,7 @@ async fn handle_registered_socket<'a>(
.write_async(writer)
.await?;
let (promise, deferred) = oneshot();
connection.send(PlayerCommand::GetRooms(promise)).await;
let rooms_list = deferred.await?;
let rooms_list = connection.get_rooms().await?;
for room in &rooms_list {
produce_on_join_cmd_messages(
&config,