Sha256: 0219184baf0c9b0282465fb9f1b73f297c8f9490f858f4eeb97227622f09b419

Contents?: true

Size: 588 Bytes

Versions: 2

Compression:

Stored size: 588 Bytes

Contents

module Oria
  class Client < EventMachine::Connection
    attr_reader :response

    def connection_completed
      @connected = true
    end

    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

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
oria-0.1.1 lib/oria/client.rb
oria-0.1.0 lib/oria/client.rb