diff --git a/autopush_rs/src/call.rs b/autopush_rs/src/call.rs index 1a848d7d..73b0f90a 100644 --- a/autopush_rs/src/call.rs +++ b/autopush_rs/src/call.rs @@ -163,6 +163,7 @@ enum Call { message_month: String, messages: Vec, }, + } #[derive(Deserialize)] diff --git a/autopush_rs/src/client.rs b/autopush_rs/src/client.rs index 3450f300..e1fb3089 100644 --- a/autopush_rs/src/client.rs +++ b/autopush_rs/src/client.rs @@ -409,6 +409,11 @@ where ClientMessage::Unregister { channel_id, code } => { self.data.process_unregister(channel_id, code) } + ClientMessage::Nack { .. } => { + self.data.srv.metrics.incr("ua.command.nack").ok(); + self.data.webpush.as_mut().unwrap().stats.nacks += 1; + ClientState::WaitingForAcks + } ClientMessage::Ack { updates } => self.data.process_acks(updates), _ => return Err("Invalid state transition".into()), } @@ -435,6 +440,11 @@ where Either::A(ClientMessage::Unregister { channel_id, code }) => { self.data.process_unregister(channel_id, code) } + Either::A(ClientMessage::Nack { .. }) => { + self.data.srv.metrics.incr("ua.command.nack").ok(); + self.data.webpush.as_mut().unwrap().stats.nacks += 1; + ClientState::WaitingForAcks + } Either::B(ServerNotification::Notification(notif)) => { let webpush = self.data.webpush.as_mut().unwrap(); webpush.unacked_direct_notifs.push(notif.clone()); diff --git a/autopush_rs/src/protocol.rs b/autopush_rs/src/protocol.rs index 510758ed..cf634b83 100644 --- a/autopush_rs/src/protocol.rs +++ b/autopush_rs/src/protocol.rs @@ -40,6 +40,12 @@ pub enum ClientMessage { }, Ack { updates: Vec }, + + Nack { + code: Option, + version: String, + }, + } #[derive(Deserialize)]