Sha256: aa3b124984f02b2ed39981c123c540e64575d9f3660336ddd1ff8552c307087a

Contents?: true

Size: 940 Bytes

Versions: 2

Compression:

Stored size: 940 Bytes

Contents

module Isomorfeus
  module Transport
    class ClientProcessor
      def self.process(json_hash)
        if json_hash.key?(:response)
          process_response(json_hash)
        elsif json_hash.key?(:notification)
          process_notification(json_hash)
        end
      end

      def self.process_notification(notification_hash)
        processor_class = "::#{notification_hash[:notification][:class]}".constantize
        processor_class.process_message(notification_hash[:notification][:message])
      end

      def self.process_response(response_hash)
        response_hash[:response][:agent_ids].keys.each do |agent_id|
          agent = Isomorfeus::Transport::RequestAgent.get!(agent_id)
          Isomorfeus::Transport.unregister_request_in_progress(agent_id)
          agent.promise.resolve(agent_response: response_hash[:response][:agent_ids][agent_id], full_response: response_hash)
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
isomorfeus-transport-1.0.0.delta8 lib/isomorfeus/transport/client_processor.rb
isomorfeus-transport-1.0.0.delta7 lib/isomorfeus/transport/client_processor.rb