forked from lavina/lavina
make PlayerCommand mod-private
This commit is contained in:
parent
8b4e963d39
commit
1e17e017cf
|
@ -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>,
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue