def run
shutdown = false
connection = Reactor.new(@opts.port, $conntype, $connio, $connopts,
$connfilters, @opts.address)
raise "Unable to start TeensyClient" unless connection.start(self)
conmsg "Connected to #{@opts.address}:#{@opts.port}. Use F10 to QUIT"
until shutdown
connection.poll(0.1)
Curses.refresh
c = Curses.getch
case c
when 32..127
publish(c.chr)
when Curses::KEY_ENTER
publish("\r\n")
when 10
publish("\n")
when 4294967295
when Curses::KEY_F10
conmsg "Quitting..."
shutdown = true
else
conmsg "Unknown key hit code - #{c.inspect}"
end
end
connection.stop
rescue SystemExit, Interrupt
conmsg "\nConnection closed exiting"
rescue Exception
conmsg "\nException caught error in client: " + $!
conmsg $@
ensure
Curses.close_screen
end