forked from lavina/lavina
handle stop connection cmd
This commit is contained in:
parent
9625120940
commit
fdaf10660e
|
@ -507,11 +507,18 @@ async fn handle_registered_socket<'a>(
|
||||||
buffer.clear();
|
buffer.clear();
|
||||||
},
|
},
|
||||||
update = connection.receiver.recv() => {
|
update = connection.receiver.recv() => {
|
||||||
if let Some(update) = update {
|
match update {
|
||||||
handle_update(&config, &user, &player_id, writer, &rooms, update).await?;
|
Some(ConnectionMessage::Update(update)) => {
|
||||||
} else {
|
handle_update(&config, &user, &player_id, writer, &rooms, update).await?;
|
||||||
log::warn!("Player is terminated, must terminate the connection");
|
}
|
||||||
break;
|
Some(ConnectionMessage::Stop(_)) => {
|
||||||
|
tracing::debug!("Connection is being terminated");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
None => {
|
||||||
|
log::warn!("Player is terminated, must terminate the connection");
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ use tokio_rustls::rustls::{Certificate, PrivateKey};
|
||||||
use tokio_rustls::TlsAcceptor;
|
use tokio_rustls::TlsAcceptor;
|
||||||
|
|
||||||
use lavina_core::auth::{Authenticator, Verdict};
|
use lavina_core::auth::{Authenticator, Verdict};
|
||||||
use lavina_core::player::{PlayerConnection, PlayerId, PlayerRegistry};
|
use lavina_core::player::{ConnectionMessage, PlayerConnection, PlayerId, PlayerRegistry};
|
||||||
use lavina_core::prelude::*;
|
use lavina_core::prelude::*;
|
||||||
use lavina_core::repo::Storage;
|
use lavina_core::repo::Storage;
|
||||||
use lavina_core::room::RoomRegistry;
|
use lavina_core::room::RoomRegistry;
|
||||||
|
@ -395,16 +395,23 @@ async fn socket_final(
|
||||||
true
|
true
|
||||||
},
|
},
|
||||||
update = conn.user_handle.receiver.recv() => {
|
update = conn.user_handle.receiver.recv() => {
|
||||||
if let Some(update) = update {
|
match update {
|
||||||
conn.handle_update(&mut events, update).await?;
|
Some(ConnectionMessage::Update(update)) => {
|
||||||
for i in &events {
|
conn.handle_update(&mut events, update).await?;
|
||||||
xml_writer.write_event_async(i).await?;
|
for i in &events {
|
||||||
|
xml_writer.write_event_async(i).await?;
|
||||||
|
}
|
||||||
|
events.clear();
|
||||||
|
xml_writer.get_mut().flush().await?;
|
||||||
|
}
|
||||||
|
Some(ConnectionMessage::Stop(_)) => {
|
||||||
|
tracing::debug!("Connection is being terminated");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
None => {
|
||||||
|
log::warn!("Player is terminated, must terminate the connection");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
events.clear();
|
|
||||||
xml_writer.get_mut().flush().await?;
|
|
||||||
} else {
|
|
||||||
log::warn!("Player is terminated, must terminate the connection");
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue