Class: Fluent::Counter::Connection
- Inherits:
-
BaseSocket
- Object
- Coolio::TCPSocket
- BaseSocket
- Fluent::Counter::Connection
- Defined in:
- lib/fluent/counter/client.rb
Instance Method Summary collapse
-
#initialize(io, on_message) ⇒ Connection
constructor
A new instance of Connection.
- #on_close ⇒ Object
- #on_connect ⇒ Object
- #on_message(data) ⇒ Object
- #send_data(data) ⇒ Object
Methods inherited from BaseSocket
Constructor Details
#initialize(io, on_message) ⇒ Connection
Returns a new instance of Connection.
199 200 201 202 203 204 |
# File 'lib/fluent/counter/client.rb', line 199 def initialize(io, ) super(io) @connection = false @buffer = '' @on_message = end |
Instance Method Details
#on_close ⇒ Object
220 221 222 |
# File 'lib/fluent/counter/client.rb', line 220 def on_close @connection = false end |
#on_connect ⇒ Object
214 215 216 217 218 |
# File 'lib/fluent/counter/client.rb', line 214 def on_connect @connection = true write @buffer @buffer = '' end |
#on_message(data) ⇒ Object
224 225 226 |
# File 'lib/fluent/counter/client.rb', line 224 def (data) @on_message.call(data) end |
#send_data(data) ⇒ Object
206 207 208 209 210 211 212 |
# File 'lib/fluent/counter/client.rb', line 206 def send_data(data) if @connection packed_write data else @buffer += pack(data) end end |