use libmudtelnet_rs::telnet::op_option;
use libmudtelnet_rs::{events::TelnetEvents, Parser};
fn main() {
let mut parser = Parser::new();
let events = parser.receive(b"hi \xFF\xFF\r\n");
for ev in events {
match ev {
TelnetEvents::DataReceive(buf) => {
println!("DATA : {:?}", String::from_utf8_lossy(&buf));
}
TelnetEvents::Negotiation(n) => {
println!("NEG : cmd={} opt={}", n.command, n.option);
}
TelnetEvents::Subnegotiation(s) => {
println!("SUB : opt={} len={}", s.option, s.buffer.len());
}
TelnetEvents::IAC(i) => {
println!("IAC : cmd={}", i.command);
}
TelnetEvents::DecompressImmediate(b) => {
println!("MCCP : boundary len={}", b.len());
}
TelnetEvents::DataSend(buf) => {
println!("SEND : {} bytes", buf.len());
}
_ => {}
}
}
if let Some(TelnetEvents::DataSend(buf)) =
parser.subnegotiation_text(op_option::GMCP, "{\"Core.Ping\":1}")
{
println!("SEND : {} bytes (GMCP)", buf.len());
}
}