Class: Oria::Client

Inherits:
EventMachine::Connection
  • Object
show all
Defined in:
lib/oria/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#responseObject (readonly)

Returns the value of attribute response.



3
4
5
# File 'lib/oria/client.rb', line 3

def response
  @response
end

Instance Method Details

#connection_completedObject



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

def connection_completed
  @connected = true
end

#receive_data(data) ⇒ Object



9
10
11
12
13
14
15
# File 'lib/oria/client.rb', line 9

def receive_data(data)
  @response = JSON.parse(data)
  # close_connection
  # Note: Benchmarks found that calling stop_event_loop is slightly quicker
  # than close_connection, which navigates the connection closing.
  EventMachine.stop_event_loop
end

#unbindObject



17
18
19
20
# File 'lib/oria/client.rb', line 17

def unbind
  raise Oria::ConnectionError.new("Could not connect to the Oria server") unless @connected
  EventMachine.stop_event_loop
end