forked from lavina/lavina
player shutdown cmds
This commit is contained in:
parent
c1dc2df150
commit
9625120940
|
@ -55,7 +55,7 @@ pub struct ConnectionId(pub AnonKey);
|
|||
/// The connection is used to send commands to the player actor and to receive updates that might be sent to the client.
|
||||
pub struct PlayerConnection {
|
||||
pub connection_id: ConnectionId,
|
||||
pub receiver: Receiver<Updates>,
|
||||
pub receiver: Receiver<ConnectionMessage>,
|
||||
player_handle: PlayerHandle,
|
||||
}
|
||||
impl PlayerConnection {
|
||||
|
@ -160,7 +160,7 @@ impl PlayerHandle {
|
|||
enum ActorCommand {
|
||||
/// Establish a new connection.
|
||||
AddConnection {
|
||||
sender: Sender<Updates>,
|
||||
sender: Sender<ConnectionMessage>,
|
||||
promise: Promise<ConnectionId>,
|
||||
},
|
||||
/// Terminate an existing connection.
|
||||
|
@ -337,7 +337,7 @@ struct PlayerRegistryInner {
|
|||
struct Player {
|
||||
player_id: PlayerId,
|
||||
storage_id: u32,
|
||||
connections: AnonTable<Sender<Updates>>,
|
||||
connections: AnonTable<Sender<ConnectionMessage>>,
|
||||
my_rooms: HashMap<RoomId, RoomHandle>,
|
||||
banned_from: HashSet<RoomId>,
|
||||
rx: Receiver<(ActorCommand, Span)>,
|
||||
|
@ -438,7 +438,7 @@ impl Player {
|
|||
_ => {}
|
||||
}
|
||||
for (_, connection) in &self.connections {
|
||||
let _ = connection.send(update.clone()).await;
|
||||
let _ = connection.send(ConnectionMessage::Update(update.clone())).await;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -589,7 +589,17 @@ impl Player {
|
|||
if ConnectionId(a) == except {
|
||||
continue;
|
||||
}
|
||||
let _ = b.send(update.clone()).await;
|
||||
let _ = b.send(ConnectionMessage::Update(update.clone())).await;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub enum ConnectionMessage {
|
||||
Update(Updates),
|
||||
Stop(StopReason),
|
||||
}
|
||||
|
||||
pub enum StopReason {
|
||||
ServerShutdown,
|
||||
InternalError,
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue