Nested Push messages
This commit is contained in:
parent
bea9c0e9e4
commit
022d056901
1 changed files with 7 additions and 5 deletions
|
@ -33,20 +33,22 @@ macro_rules! handle_request {
|
|||
}
|
||||
|
||||
macro_rules! handle_push {
|
||||
($($name:ident;)*) => {
|
||||
($($name:ident $(, $inner_package:ident)?;)*) => {
|
||||
fn handle_push(player: &mut super::player::Player, mut msg: Message) {
|
||||
use ::shorekeeper_protocol::{MessageID, Protobuf};
|
||||
|
||||
::paste::paste! {
|
||||
match msg.get_message_id() {
|
||||
$(
|
||||
::shorekeeper_protocol::[<$name Push>]::MESSAGE_ID => {
|
||||
let Ok(push) = ::shorekeeper_protocol::[<$name Push>]::decode(&*msg.remove_payload()) else {
|
||||
tracing::debug!("failed to decode {}, player_id: {}", stringify!([<$name Push>]), player.basic_info.id);
|
||||
::shorekeeper_protocol::$($inner_package::)?[<$name Push>]::MESSAGE_ID => {
|
||||
let Ok(push) = ::shorekeeper_protocol::$($inner_package::)?[<$name Push>]::decode(&*msg.remove_payload()) else {
|
||||
tracing::debug!("failed to decode {}, player_id: {}", stringify!($($inner_package::)?[<$name Push>]), player.basic_info.id);
|
||||
return;
|
||||
};
|
||||
|
||||
[<on_ $name:snake _push>](player, push);
|
||||
tracing::debug!("logic: processing push {}", stringify!($($inner_package::)?[<$name Push>]));
|
||||
|
||||
[<on_ $($inner_package:snake _)? $name:snake _push>](player, push);
|
||||
},
|
||||
)*
|
||||
unhandled => ::tracing::warn!("can't find handler for push with message_id={unhandled}")
|
||||
|
|
Loading…
Reference in a new issue