Class: TinyQ::ClientConnection

Inherits:
EventMachine::Connection
  • Object
show all
Includes:
EventMachine::Protocols::LineText2
Defined in:
lib/tinyq/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeClientConnection

Returns a new instance of ClientConnection.



7
8
9
# File 'lib/tinyq/client.rb', line 7

def initialize
    set_delimiter TinyQ::DELIMITER
end

Instance Attribute Details

#clientObject

Returns the value of attribute client.



5
6
7
# File 'lib/tinyq/client.rb', line 5

def client
  @client
end

Instance Method Details

#receive_line(message) ⇒ Object



11
12
13
14
15
16
17
18
# File 'lib/tinyq/client.rb', line 11

def receive_line message
    begin
        reply = JSON.parse(message)
        @client.callbacks.each { |c| c.call(reply) }
    rescue Exception => e
        puts e
    end
end