forked from lavina/lavina
Compare commits
1 Commits
fdaf10660e
...
31ec30c2ef
Author | SHA1 | Date |
---|---|---|
Nikita Vilunov | 31ec30c2ef |
|
@ -54,7 +54,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.
|
/// 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 struct PlayerConnection {
|
||||||
pub connection_id: ConnectionId,
|
pub connection_id: ConnectionId,
|
||||||
pub receiver: Receiver<Updates>,
|
pub receiver: Receiver<ConnectionMessage>,
|
||||||
player_handle: PlayerHandle,
|
player_handle: PlayerHandle,
|
||||||
}
|
}
|
||||||
impl PlayerConnection {
|
impl PlayerConnection {
|
||||||
|
@ -152,7 +152,7 @@ impl PlayerHandle {
|
||||||
enum ActorCommand {
|
enum ActorCommand {
|
||||||
/// Establish a new connection.
|
/// Establish a new connection.
|
||||||
AddConnection {
|
AddConnection {
|
||||||
sender: Sender<Updates>,
|
sender: Sender<ConnectionMessage>,
|
||||||
promise: Promise<ConnectionId>,
|
promise: Promise<ConnectionId>,
|
||||||
},
|
},
|
||||||
/// Terminate an existing connection.
|
/// Terminate an existing connection.
|
||||||
|
@ -329,7 +329,7 @@ struct PlayerRegistryInner {
|
||||||
struct Player {
|
struct Player {
|
||||||
player_id: PlayerId,
|
player_id: PlayerId,
|
||||||
storage_id: u32,
|
storage_id: u32,
|
||||||
connections: AnonTable<Sender<Updates>>,
|
connections: AnonTable<Sender<ConnectionMessage>>,
|
||||||
my_rooms: HashMap<RoomId, RoomHandle>,
|
my_rooms: HashMap<RoomId, RoomHandle>,
|
||||||
banned_from: HashSet<RoomId>,
|
banned_from: HashSet<RoomId>,
|
||||||
rx: Receiver<ActorCommand>,
|
rx: Receiver<ActorCommand>,
|
||||||
|
@ -413,7 +413,7 @@ impl Player {
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
for (_, connection) in &self.connections {
|
for (_, connection) in &self.connections {
|
||||||
let _ = connection.send(update.clone()).await;
|
let _ = connection.send(ConnectionMessage::Update(update.clone())).await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -557,7 +557,17 @@ impl Player {
|
||||||
if ConnectionId(a) == except {
|
if ConnectionId(a) == except {
|
||||||
continue;
|
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