Class: EM::Protocols::ZMQConnectionHandler
- Inherits:
-
Object
- Object
- EM::Protocols::ZMQConnectionHandler
- Defined in:
- lib/zebra/proxy_server.rb
Instance Attribute Summary collapse
-
#received ⇒ Object
readonly
Returns the value of attribute received.
Instance Method Summary collapse
-
#initialize(connection) ⇒ ZMQConnectionHandler
constructor
A new instance of ZMQConnectionHandler.
- #on_readable(socket, messages) ⇒ Object
- #send_msg(*parts) ⇒ Object
Constructor Details
#initialize(connection) ⇒ ZMQConnectionHandler
Returns a new instance of ZMQConnectionHandler.
87 88 89 90 91 92 |
# File 'lib/zebra/proxy_server.rb', line 87 def initialize(connection) @connection = connection @client_fiber = Fiber.current @connection.setsockopt(ZMQ::IDENTITY, "req-#{@client_fiber.object_id}") @connection.handler = self end |
Instance Attribute Details
#received ⇒ Object (readonly)
Returns the value of attribute received.
85 86 87 |
# File 'lib/zebra/proxy_server.rb', line 85 def received @received end |
Instance Method Details
#on_readable(socket, messages) ⇒ Object
101 102 103 |
# File 'lib/zebra/proxy_server.rb', line 101 def on_readable(socket, ) @client_fiber.resume() end |
#send_msg(*parts) ⇒ Object
94 95 96 97 98 99 |
# File 'lib/zebra/proxy_server.rb', line 94 def send_msg(*parts) queued = @connection.send_msg(*parts) @connection.register_readable = Fiber.yield .map(&:copy_out_string) end |