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