class BBS::Telnet::Parser

Telnet commands taken out of a byte stream, one byte at a time: a small state machine, shared by the board’s own line (BBS::Telnet) and both directions of a BBS::Gateway::Link. Data bytes come out, a doubled IAC as one 255; each option command and subnegotiation goes to the block given to ::new.

parser = BBS::Telnet::Parser.new { |command, argument| p [command, argument] }
parser.parse("hi\xFF\xFB\x01".b)   # => "hi", and prints [251, 1]

The block gets (command, option) for WILL, WONT, DO and DONT, and (SB, bytes) for a subnegotiation, bytes an Array of Integer whose first is the option; a subnegotiation keeps at most MAX_SUBNEGOTIATION bytes, the rest is read and dropped. Other commands (NOP, GA …) are dropped.