Class: Smartware::PubSubClient::PubSubHandler

Inherits:
EventMachine::Connection
  • Object
show all
Includes:
EventMachine::Protocols::LineProtocol
Defined in:
lib/smartware/pub_sub_client.rb

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ PubSubHandler

Returns a new instance of PubSubHandler.



41
42
43
# File 'lib/smartware/pub_sub_client.rb', line 41

def initialize(client)
  @client = client
end

Instance Method Details

#receive_line(line) ⇒ Object



49
50
51
52
53
# File 'lib/smartware/pub_sub_client.rb', line 49

def receive_line(line)
  data = JSON.load line

  @client.receive data
end

#send_record(data) ⇒ Object



55
56
57
# File 'lib/smartware/pub_sub_client.rb', line 55

def send_record(data)
  send_data(JSON.dump(data) + "\r\n")
end

#unbindObject



45
46
47
# File 'lib/smartware/pub_sub_client.rb', line 45

def unbind
  @client.broken
end