class BBS::Zmodem::Sender
One ZMODEM batch send over a session. Zmodem.send_files is the usual way in.
Public Class Methods
Source
# File lib/bbs/zmodem/sender.rb, line 10 def initialize(session, telnet: true) @in = Input.new(session) @out = Output.new(session, telnet: telnet) @window = 0 end
Creates a sender writing to and reading raw bytes from session; telnet doubles 0xFF bytes as telnet IAC.
Public Instance Methods
Source
# File lib/bbs/zmodem/sender.rb, line 22 def run(files, wait:) files = files.map { |name, data, mtime| [File.basename(name.to_s), data.to_s.b, mtime || Time.now] } @out.emit(RZ_COMMAND) handshake(wait) files.each_with_index { |file, i| send_file(*file, files[i..]) } finish rescue Cancelled, Timeout => e @out.emit(ABORT) e.is_a?(Cancelled) ? :cancelled : :timeout rescue Hangup, IOError, SystemCallError :hangup end
Sends files (as for Zmodem.send_files): writes rz and CR, waits up to wait seconds for ZRINIT, offers and streams each file, then ends the session with ZFIN. Writes the abort sequence on cancel or timeout.
Returns :ok, :cancelled, :timeout or :hangup.