1use libmudtelnet_rs::telnet::op_option;
2use libmudtelnet_rs::{events::TelnetEvents, Parser};
3
4fn main() {
5 let mut parser = Parser::new();
7
8 let events = parser.receive(b"hi \xFF\xFF\r\n");
10 for ev in events {
11 match ev {
12 TelnetEvents::DataReceive(buf) => {
13 println!("DATA : {:?}", String::from_utf8_lossy(&buf));
14 }
15 TelnetEvents::Negotiation(n) => {
16 println!("NEG : cmd={} opt={}", n.command, n.option);
17 }
18 TelnetEvents::Subnegotiation(s) => {
19 println!("SUB : opt={} len={}", s.option, s.buffer.len());
20 }
21 TelnetEvents::IAC(i) => {
22 println!("IAC : cmd={}", i.command);
23 }
24 TelnetEvents::DecompressImmediate(b) => {
25 println!("MCCP : boundary len={}", b.len());
26 }
27 TelnetEvents::DataSend(buf) => {
28 println!("SEND : {} bytes", buf.len());
30 }
31 _ => {}
32 }
33 }
34
35 if let Some(TelnetEvents::DataSend(buf)) =
37 parser.subnegotiation_text(op_option::GMCP, "{\"Core.Ping\":1}")
38 {
39 println!("SEND : {} bytes (GMCP)", buf.len());
40 }
41}