First naive implementation of tcp server. Not working right now

This commit is contained in:
Jonas Zeunert
2024-12-30 15:41:58 +01:00
parent 30f374bfc4
commit 5bd7626843
4 changed files with 88 additions and 8 deletions

23
flutr.rs Normal file
View File

@@ -0,0 +1,23 @@
pub struct FlutR {
stream: TcpStream,
msgs: PixelMsgs,
}
impl FlutR {
fn new(host: Host, port: u16, msgs: PixelMsgs) -> Result<Self, std::io::Error> {
let stream = TcpStream::connect(format!("{host}:{port}"))?;
Ok(FlutR { stream, msgs })
}
fn flut(&mut self) {
for msg in self.msgs.clone() {
dbg!(&msg);
let result = self.stream.write(msg.as_str().as_bytes());
match result {
Ok(_) => (),
Err(err) => eprintln!("{err}"),
}
let _ = self.stream.flush();
}
}
}