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.
62 63 64 65 66 67 68 69 |
# File 'lib/droonga/client/connection/droonga-protocol/coolio.rb', line 62 def initialize(*args) super(*args) do |engine| @engines << engine handle_engine(engine) end @requests = {} @engines = [] end |
Instance Method Details
#close ⇒ Object
71 72 73 74 75 76 77 |
# File 'lib/droonga/client/connection/droonga-protocol/coolio.rb', line 71 def close super @engines.each do |engine| engine.close end @engines.clear end |
#droonga_name ⇒ Object
87 88 89 |
# File 'lib/droonga/client/connection/droonga-protocol/coolio.rb', line 87 def droonga_name "#{host}:#{port}/droonga" end |
#host ⇒ Object
79 80 81 |
# File 'lib/droonga/client/connection/droonga-protocol/coolio.rb', line 79 def host @listen_socket.addr[3] end |
#port ⇒ Object
83 84 85 |
# File 'lib/droonga/client/connection/droonga-protocol/coolio.rb', line 83 def port @listen_socket.addr[1] end |
#received?(id) ⇒ Boolean
102 103 104 105 106 107 108 |
# File 'lib/droonga/client/connection/droonga-protocol/coolio.rb', line 102 def received?(id) if @requests.key?(id) @requests[id][:received] else true end end |
#register(id, &callback) ⇒ Object
91 92 93 94 95 96 |
# File 'lib/droonga/client/connection/droonga-protocol/coolio.rb', line 91 def register(id, &callback) @requests[id] = { :received => false, :callback => callback, } end |
#unregister(id) ⇒ Object
98 99 100 |
# File 'lib/droonga/client/connection/droonga-protocol/coolio.rb', line 98 def unregister(id) @requests.delete(id) end |