Add map ping support #30

This commit is contained in:
NG (Graham) committed 2025-08-03 16:39:16 -04:00
1 parent 721922c4ea
commit 580ce69839
4 files changed
+50

No files matched your search

+30
View File
@@ -0,0 +1,30 @@
pub struct PingMap {
msg_router: tokio::sync::mpsc::Sender<crate::matches::GameMessage>,
}
pub(super) fn handler(init_ctx: &crate::InitConfig) -> crate::handlers::SimpleRlnl<rlnl::events::ingame::MapPing, PingMap> {
crate::handlers::SimpleRlnl::new(PingMap::new(init_ctx))
}
impl PingMap {
fn new(init_ctx: &crate::InitConfig) -> Self {
Self {
msg_router: init_ctx.matches_chann.clone(),
}
}
}
#[async_trait::async_trait]
impl crate::handlers::RlnlEventCodeHandler for PingMap {
type In = rlnl::events::ingame::MapPing;
const CODE: rlnl::event_code::NetworkEvent = rlnl::event_code::NetworkEvent::MapPingEvent;
async fn handle(&self, data: Self::In, _peer: &std::sync::Arc<literustlib_server::Connection<crate::PacketData>>, user: &crate::UserData, _sender: &std::sync::Arc<literustlib_server::DataSender<crate::PacketData>>) {
if let Some(user_info) = user.user().await {
super::log_channel_send_failure(self.msg_router.send(crate::matches::GameMessage::MapPing {
user_id: user_info.user_id(),
ping: data,
}).await);
}
}
}
+3
View File
@@ -10,6 +10,7 @@ mod kill_player;
mod client_unregister;
mod flipper_start;
mod self_destruct_elimination;
mod map_ping;
pub async fn handler(init_ctx: &crate::InitConfig) -> crate::handler::LnlEventHandler {
crate::handler::LnlEventHandler::new(init_ctx.users.clone(), crate::vehicle_motion::handler(init_ctx))
@@ -173,6 +174,7 @@ pub async fn handler(init_ctx: &crate::InitConfig) -> crate::handler::LnlEventHa
rlnl::events::ingame::UpdateVotingAfterBattle,
>::handler(init_ctx))
.add(self_destruct_elimination::handler(init_ctx))
.add(map_ping::handler(init_ctx))
}
#[inline]
@@ -208,6 +210,7 @@ mod _broadcast_impls {
impl Broadcastable for rlnl::events::ingame::CosmeticAction {}
impl Broadcastable for rlnl::events::ingame::UpdateVotingAfterBattle {}
impl Broadcastable for rlnl::events::ingame::TeleportActivateEffect {}
impl Broadcastable for rlnl::events::ingame::MapPing {}
impl Broadcastable for rlnl::events::sync::UpdateGameModeSettings {}
impl Broadcastable for rlnl::events::GameTime {}