forked from lavina/lavina
make PlayerCommand mod-private
This commit is contained in:
parent
8b4e963d39
commit
1e17e017cf
|
@ -89,8 +89,10 @@ impl PlayerConnection {
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn send(&self, command: PlayerCommand) {
|
pub async fn get_rooms(&self) -> Result<Vec<RoomInfo>> {
|
||||||
self.player_handle.send(command).await;
|
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 */
|
/** Commands from connections */
|
||||||
AddConnection {
|
AddConnection {
|
||||||
sender: Sender<Updates>,
|
sender: Sender<Updates>,
|
||||||
|
|
|
@ -7,7 +7,7 @@ use tokio::net::tcp::{ReadHalf, WriteHalf};
|
||||||
use tokio::net::{TcpListener, TcpStream};
|
use tokio::net::{TcpListener, TcpStream};
|
||||||
use tokio::sync::oneshot::channel;
|
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::core::room::{RoomId, RoomInfo, RoomRegistry};
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
use crate::protos::irc::client::{client_message, ClientMessage};
|
use crate::protos::irc::client::{client_message, ClientMessage};
|
||||||
|
@ -196,9 +196,7 @@ async fn handle_registered_socket<'a>(
|
||||||
.write_async(writer)
|
.write_async(writer)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
let (promise, deferred) = oneshot();
|
let rooms_list = connection.get_rooms().await?;
|
||||||
connection.send(PlayerCommand::GetRooms(promise)).await;
|
|
||||||
let rooms_list = deferred.await?;
|
|
||||||
for room in &rooms_list {
|
for room in &rooms_list {
|
||||||
produce_on_join_cmd_messages(
|
produce_on_join_cmd_messages(
|
||||||
&config,
|
&config,
|
||||||
|
|
Loading…
Reference in New Issue