Class: EM::Protocols::ZMQConnectionHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/zebra/proxy_server.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#receivedObject (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, messages)
  @client_fiber.resume(messages)
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
  messages = Fiber.yield
  messages.map(&:copy_out_string)
end