broadcast disconnect on actor stop
This commit is contained in:
parent
9d13b5c04a
commit
8e4c13a8dd
|
@ -13,7 +13,7 @@ use crate::{
|
|||
packet::{
|
||||
rw::{read_packet, write_packet},
|
||||
ConnectionKind, Packet, PacketData,
|
||||
PacketData_variants::{Connect, HolePunch, Init, UdpInit},
|
||||
PacketData_variants::{Connect, Disconnect, HolePunch, Init, UdpInit},
|
||||
CLIENT_NAME_SIZE,
|
||||
},
|
||||
protocol::String,
|
||||
|
@ -113,7 +113,7 @@ impl PlayerActor {
|
|||
match message {
|
||||
WriteMessage::Data(Packet { user_id, udp, data }) => {
|
||||
// trace!("writing packet {udp:?}, {data:?}");
|
||||
let res = if udp {
|
||||
let res = if udp && addr.is_some() {
|
||||
async {
|
||||
let Some(addr) = addr else {
|
||||
trace!("no address set yet");
|
||||
|
@ -180,7 +180,7 @@ impl PlayerActor {
|
|||
connection_kind: connect.kind,
|
||||
name: connect.client_name,
|
||||
write_sender: sender,
|
||||
udp_port
|
||||
udp_port,
|
||||
},
|
||||
)
|
||||
.instrument(span)
|
||||
|
@ -214,7 +214,14 @@ impl Actor for PlayerActor {
|
|||
|
||||
Ok(())
|
||||
}
|
||||
async fn stopped(self) -> Self::Stop {}
|
||||
async fn stopped(self) -> Self::Stop {
|
||||
broadcast_packet(Packet {
|
||||
user_id: self.id,
|
||||
udp: false,
|
||||
data: PacketData::Disconnect(Disconnect),
|
||||
})
|
||||
.await;
|
||||
}
|
||||
}
|
||||
struct StopError;
|
||||
impl Handler<StopError> for PlayerActor {
|
||||
|
|
Loading…
Reference in a new issue