class BBS::Gateway::Link
One crossing: the bytes of the other board down to the caller, the caller’s up to it, each way through its own Telnet::Parser. The other board’s telnet commands go to a Negotiation; the caller’s window size changes are kept by the session and passed on.
Constants
- CHUNK
-
Bytes read from either side at a time.
- DATA_IAC
-
A data byte 255, and the same doubled for a telnet line.
Attributes
The bytes the other board sent the caller so far, telnet commands not counted.
Public Class Methods
# File lib/bbs/gateway/link.rb, line 27 def initialize(session, remote, terminal:, idle: nil, bridge: nil) @session = session @client = session.line @remote = remote @bridge = bridge @idle = idle @received = 0 @hung_up = false @heard = monotonic @mu = Mutex.new @negotiation = negotiation(bridge ? 'ANSI' : terminal, session.petscii? && bridge.nil?) end
Creates a link between the caller’s session and the remote socket of the other board. terminal is the terminal type reported when the other board asks; idle the seconds the line may stay silent both ways (nil: no limit); bridge an AsciiBridge that translates both ways (nil: the bytes cross as they are), behind which a PETSCII caller is an ANSI terminal to the other board.
Public Instance Methods
Source
# File lib/bbs/gateway/link.rb, line 49 def run up = Thread.new { upstream } downstream @hung_up ensure up.kill unless up.nil? || (@hung_up && up.join(1)) end
Carries the bytes both ways until one side hangs up: the other board’s down to the caller in this thread, the caller’s up in a new one.
Returns true when the caller hung up or the line stayed silent both ways for the idle seconds, false when the other board hung up. The caller’s side ends by shutting the other board’s socket down, which wakes the reader of this thread; it is closed by the gateway, never by a thread that may be killed halfway through closing it.