Class: Droonga::Client::Connection::DroongaProtocol::Coolio::Sender
- Inherits:
-
Coolio::TCPSocket
- Object
- Coolio::TCPSocket
- Droonga::Client::Connection::DroongaProtocol::Coolio::Sender
- Defined in:
- lib/droonga/client/connection/droonga-protocol/coolio.rb
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize(*args) ⇒ Sender
constructor
A new instance of Sender.
- #on_connect ⇒ Object
- #on_connect_failed ⇒ Object
- #send(tag, data, &on_error) ⇒ Object
Constructor Details
#initialize(*args) ⇒ Sender
Returns a new instance of Sender.
72 73 74 75 76 77 |
# File 'lib/droonga/client/connection/droonga-protocol/coolio.rb', line 72 def initialize(*args) super @connected = false @failed_to_connect = false @buffer = [] end |
Instance Method Details
#close ⇒ Object
79 80 81 82 |
# File 'lib/droonga/client/connection/droonga-protocol/coolio.rb', line 79 def close return if @failed_to_connect super end |
#on_connect ⇒ Object
97 98 99 100 101 102 103 |
# File 'lib/droonga/client/connection/droonga-protocol/coolio.rb', line 97 def on_connect @connected = true @buffer.each do |,| write() end @buffer.clear end |
#on_connect_failed ⇒ Object
105 106 107 108 109 110 111 112 |
# File 'lib/droonga/client/connection/droonga-protocol/coolio.rb', line 105 def on_connect_failed @failed_to_connect = true @buffer.each do |, on_error| _, _, = MessagePack.unpack() on_error.call() end @buffer.clear end |
#send(tag, data, &on_error) ⇒ Object
84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/droonga/client/connection/droonga-protocol/coolio.rb', line 84 def send(tag, data, &on_error) if @failed_to_connect on_error.call(data) end = [tag, Time.now.to_i, data] = MessagePackPacker.pack() if @connected write() else @buffer << [, on_error] end end |