Class: ZMQMachine::Device::Forwarder::Handler
- Inherits:
-
Object
- Object
- ZMQMachine::Device::Forwarder::Handler
- Defined in:
- lib/zm/devices/forwarder.rb
Instance Attribute Summary collapse
-
#socket_out ⇒ Object
Returns the value of attribute socket_out.
Instance Method Summary collapse
-
#initialize(reactor, address, verbose = false) ⇒ Handler
constructor
A new instance of Handler.
- #on_attach(socket) ⇒ Object
- #on_readable(socket, messages) ⇒ Object
- #on_writable(socket) ⇒ Object
Constructor Details
#initialize(reactor, address, verbose = false) ⇒ Handler
Returns a new instance of Handler.
68 69 70 71 72 |
# File 'lib/zm/devices/forwarder.rb', line 68 def initialize reactor, address, verbose = false @reactor = reactor @address = address @verbose = verbose end |
Instance Attribute Details
#socket_out ⇒ Object
Returns the value of attribute socket_out.
66 67 68 |
# File 'lib/zm/devices/forwarder.rb', line 66 def socket_out @socket_out end |
Instance Method Details
#on_attach(socket) ⇒ Object
74 75 76 77 78 79 80 |
# File 'lib/zm/devices/forwarder.rb', line 74 def on_attach socket socket.identity = "forwarder.#{Kernel.rand(999_999_999)}" rc = socket.bind @address #FIXME: error handling! socket.subscribe_all if :sub == socket.kind end |
#on_readable(socket, messages) ⇒ Object
86 87 88 89 90 |
# File 'lib/zm/devices/forwarder.rb', line 86 def on_readable socket, .each { |msg| puts "[fwd] [#{msg.copy_out_string}]" } if @verbose socket_out. if @socket_out end |
#on_writable(socket) ⇒ Object
82 83 84 |
# File 'lib/zm/devices/forwarder.rb', line 82 def on_writable socket @reactor.deregister_writable socket end |