Sha256: 50fe8e5e154396b1cc468ee1c2461b05fd01b983170cee07e035687dbf43aea2

Contents?: true

Size: 1.05 KB

Versions: 20

Compression:

Stored size: 1.05 KB

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][:channel], 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)
          unless agent.promise.realized?
            agent.full_response = response_hash
            agent.response = response_hash[:response][:agent_ids][agent_id]
            agent.promise.resolve(agent)
          end
        end
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
isomorfeus-transport-1.0.0.zeta23 lib/isomorfeus/transport/client_processor.rb
isomorfeus-transport-1.0.0.zeta22 lib/isomorfeus/transport/client_processor.rb
isomorfeus-transport-1.0.0.zeta21 lib/isomorfeus/transport/client_processor.rb
isomorfeus-transport-1.0.0.zeta20 lib/isomorfeus/transport/client_processor.rb
isomorfeus-transport-1.0.0.zeta19 lib/isomorfeus/transport/client_processor.rb
isomorfeus-transport-1.0.0.zeta18 lib/isomorfeus/transport/client_processor.rb
isomorfeus-transport-1.0.0.zeta17 lib/isomorfeus/transport/client_processor.rb
isomorfeus-transport-1.0.0.zeta16 lib/isomorfeus/transport/client_processor.rb
isomorfeus-transport-1.0.0.zeta15 lib/isomorfeus/transport/client_processor.rb
isomorfeus-transport-1.0.0.zeta14 lib/isomorfeus/transport/client_processor.rb
isomorfeus-transport-1.0.0.zeta13 lib/isomorfeus/transport/client_processor.rb
isomorfeus-transport-1.0.0.zeta12 lib/isomorfeus/transport/client_processor.rb
isomorfeus-transport-1.0.0.zeta11 lib/isomorfeus/transport/client_processor.rb
isomorfeus-transport-1.0.0.zeta10 lib/isomorfeus/transport/client_processor.rb
isomorfeus-transport-1.0.0.zeta9 lib/isomorfeus/transport/client_processor.rb
isomorfeus-transport-1.0.0.zeta8 lib/isomorfeus/transport/client_processor.rb
isomorfeus-transport-1.0.0.zeta7 lib/isomorfeus/transport/client_processor.rb
isomorfeus-transport-1.0.0.zeta6 lib/isomorfeus/transport/client_processor.rb
isomorfeus-transport-1.0.0.zeta5 lib/isomorfeus/transport/client_processor.rb
isomorfeus-transport-1.0.0.zeta4 lib/isomorfeus/transport/client_processor.rb