@@ -61,8 +61,8 @@ pub enum ProtoEvent {
6161 /// Ping event for tracking unresponsive clients.
6262 /// A client has to respond with [`ProtoEvent::Pong`].
6363 Ping ,
64- /// Response to [`ProtoEvent::Ping`]
65- Pong ,
64+ /// Response to [`ProtoEvent::Ping`], true if emulation is enabled / available
65+ Pong ( bool ) ,
6666}
6767
6868impl Display for ProtoEvent {
@@ -73,7 +73,13 @@ impl Display for ProtoEvent {
7373 ProtoEvent :: Ack ( s) => write ! ( f, "Ack({s})" ) ,
7474 ProtoEvent :: Input ( e) => write ! ( f, "{e}" ) ,
7575 ProtoEvent :: Ping => write ! ( f, "ping" ) ,
76- ProtoEvent :: Pong => write ! ( f, "pong" ) ,
76+ ProtoEvent :: Pong ( alive) => {
77+ write ! (
78+ f,
79+ "pong: {}" ,
80+ if * alive { "alive" } else { "not available" }
81+ )
82+ }
7783 }
7884 }
7985}
@@ -110,7 +116,7 @@ impl ProtoEvent {
110116 } ,
111117 } ,
112118 ProtoEvent :: Ping => EventType :: Ping ,
113- ProtoEvent :: Pong => EventType :: Pong ,
119+ ProtoEvent :: Pong ( _ ) => EventType :: Pong ,
114120 ProtoEvent :: Enter ( _) => EventType :: Enter ,
115121 ProtoEvent :: Leave ( _) => EventType :: Leave ,
116122 ProtoEvent :: Ack ( _) => EventType :: Ack ,
@@ -164,7 +170,7 @@ impl TryFrom<[u8; MAX_EVENT_SIZE]> for ProtoEvent {
164170 } ,
165171 ) ) ) ,
166172 EventType :: Ping => Ok ( Self :: Ping ) ,
167- EventType :: Pong => Ok ( Self :: Pong ) ,
173+ EventType :: Pong => Ok ( Self :: Pong ( decode_u8 ( & mut buf ) ? != 0 ) ) ,
168174 EventType :: Enter => Ok ( Self :: Enter ( decode_u8 ( & mut buf) ?. try_into ( ) ?) ) ,
169175 EventType :: Leave => Ok ( Self :: Leave ( decode_u32 ( & mut buf) ?) ) ,
170176 EventType :: Ack => Ok ( Self :: Ack ( decode_u32 ( & mut buf) ?) ) ,
@@ -228,7 +234,7 @@ impl From<ProtoEvent> for ([u8; MAX_EVENT_SIZE], usize) {
228234 } ,
229235 } ,
230236 ProtoEvent :: Ping => { }
231- ProtoEvent :: Pong => { }
237+ ProtoEvent :: Pong ( alive ) => encode_u8 ( buf , len , alive as u8 ) ,
232238 ProtoEvent :: Enter ( pos) => encode_u8 ( buf, len, pos as u8 ) ,
233239 ProtoEvent :: Leave ( serial) => encode_u32 ( buf, len, serial) ,
234240 ProtoEvent :: Ack ( serial) => encode_u32 ( buf, len, serial) ,
0 commit comments