class ProconBypassMan::Bypass
Attributes
gadget[RW]
monitor[RW]
procon[RW]
Public Class Methods
new(gadget: , procon: , monitor: )
click to toggle source
# File lib/procon_bypass_man/bypass.rb, line 3 def initialize(gadget: , procon: , monitor: ) self.gadget = gadget self.procon = procon self.monitor = monitor end
Public Instance Methods
send_gadget_to_procon!()
click to toggle source
ゆっくりでいい
# File lib/procon_bypass_man/bypass.rb, line 10 def send_gadget_to_procon! monitor.record(:start_function) input = nil begin sleep($will_interval_1_6) input = self.gadget.read_nonblock(128) ProconBypassMan.logger.debug { ">>> #{input.unpack("H*")}" } rescue IO::EAGAINWaitReadable monitor.record(:eagain_wait_readable_on_read) return if $will_terminate_token retry end begin self.procon.write_nonblock(input) rescue IO::EAGAINWaitReadable monitor.record(:eagain_wait_readable_on_write) return end monitor.record(:end_function) end
send_procon_to_gadget!()
click to toggle source
# File lib/procon_bypass_man/bypass.rb, line 32 def send_procon_to_gadget! monitor.record(:start_function) output = nil begin sleep($will_interval_0_0_0_5) output = self.procon.read_nonblock(128) ProconBypassMan.logger.debug { "<<< #{output.unpack("H*")}" } rescue IO::EAGAINWaitReadable monitor.record(:eagain_wait_readable_on_read) return if $will_terminate_token retry end begin self.gadget.write_nonblock(ProconBypassMan::Processor.new(output).process) rescue IO::EAGAINWaitReadable monitor.record(:eagain_wait_readable_on_write) return end monitor.record(:end_function) end