Class: Droonga::Client::Connection::DroongaProtocol::Coolio::Receiver
- Inherits:
-
Coolio::TCPServer
- Object
- Coolio::TCPServer
- Droonga::Client::Connection::DroongaProtocol::Coolio::Receiver
- Defined in:
- lib/droonga/client/connection/droonga-protocol/coolio.rb
Instance Method Summary collapse
- #close ⇒ Object
- #droonga_name ⇒ Object
- #host ⇒ Object
-
#initialize(*args) ⇒ Receiver
constructor
A new instance of Receiver.
- #port ⇒ Object
- #received?(id) ⇒ Boolean
- #register(id, &callback) ⇒ Object
- #unregister(id) ⇒ Object
Constructor Details
#initialize(*args) ⇒ Receiver
Returns a new instance of Receiver.
94 95 96 97 98 99 100 101 |
# File 'lib/droonga/client/connection/droonga-protocol/coolio.rb', line 94 def initialize(*args) super(*args) do |engine| @engines << engine handle_engine(engine) end @requests = {} @engines = [] end |
Instance Method Details
#close ⇒ Object
103 104 105 106 107 108 109 |
# File 'lib/droonga/client/connection/droonga-protocol/coolio.rb', line 103 def close super engines = @engines.dup engines.each do |engine| engine.close end end |
#droonga_name ⇒ Object
119 120 121 |
# File 'lib/droonga/client/connection/droonga-protocol/coolio.rb', line 119 def droonga_name "#{host}:#{port}/droonga" end |
#host ⇒ Object
111 112 113 |
# File 'lib/droonga/client/connection/droonga-protocol/coolio.rb', line 111 def host @listen_socket.addr[3] end |
#port ⇒ Object
115 116 117 |
# File 'lib/droonga/client/connection/droonga-protocol/coolio.rb', line 115 def port @listen_socket.addr[1] end |
#received?(id) ⇒ Boolean
134 135 136 137 138 139 140 |
# File 'lib/droonga/client/connection/droonga-protocol/coolio.rb', line 134 def received?(id) if @requests.key?(id) @requests[id][:received] else true end end |
#register(id, &callback) ⇒ Object
123 124 125 126 127 128 |
# File 'lib/droonga/client/connection/droonga-protocol/coolio.rb', line 123 def register(id, &callback) @requests[id] = { :received => false, :callback => callback, } end |
#unregister(id) ⇒ Object
130 131 132 |
# File 'lib/droonga/client/connection/droonga-protocol/coolio.rb', line 130 def unregister(id) @requests.delete(id) end |