From 6c0260e42f5f6c3a99d8306cddd8eb795b4792bb Mon Sep 17 00:00:00 2001 From: Noa Aarts Date: Sat, 5 Oct 2024 00:29:54 +0200 Subject: [PATCH] fix: start binary responses --- src/binary_protocol.rs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/binary_protocol.rs b/src/binary_protocol.rs index 78c369a..9f18a22 100644 --- a/src/binary_protocol.rs +++ b/src/binary_protocol.rs @@ -88,7 +88,23 @@ impl MEEHHEH for BinaryParser { impl Responder for BinaryParser { async fn unparse(&self, response: Response, writer: &mut W) -> io::Result<()> { - todo!() + let help_text = format!( + " +You found the binary protocol help text +you can get this by sending ({:02X}) to the server +To get the size of a canvas, send ({:02X}) (u8 canvas) to the server +To set a pixel using RGB, use ({:02X}) (u8 canvas) (x as u16_le) (y as u16_le) (u8 r) (u8 g) (u8 b) +", + HELP_BIN, SIZE_BIN, SET_PX_RGB_BIN + ); + match response { + Response::Help => writer.write_all(help_text.as_bytes()).await, + Response::Size(x, y) => { + writer.write_u16_le(x).await?; + writer.write_u16_le(y).await + } + Response::GetPixel(_, _, c) => writer.write_all(&c).await, + } } }