Class: Isomorfeus::Transport::ClientProcessor
- Inherits:
-
Object
- Object
- Isomorfeus::Transport::ClientProcessor
- Defined in:
- lib/isomorfeus/transport/client_processor.rb
Class Method Summary collapse
- .process(json_hash) ⇒ Object
- .process_message(message_hash) ⇒ Object
- .process_response(response_hash) ⇒ Object
Class Method Details
.process(json_hash) ⇒ Object
4 5 6 7 8 9 10 |
# File 'lib/isomorfeus/transport/client_processor.rb', line 4 def self.process(json_hash) if json_hash.key?(:response) process_response(json_hash) elsif json_hash.key?(:notification) (json_hash) end end |
.process_message(message_hash) ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/isomorfeus/transport/client_processor.rb', line 12 def self.() processor_class_name = [:notification][:class] Isomorfeus.raise_error(message: "Not a valid channel class #{processor_class_name}!") unless Isomorfeus.valid_channel_class_name?(processor_class_name) processor_class = Isomorfeus.cached_channel_class(processor_class_name) unless processor_class.respond_to?(:process_message) Isomorfeus.raise_error(message: "Cannot process message, #{processor_class} must be a Channel and must have the on_message block defined!") end processor_class.([:notification][:message], [:notification][:error], [:notification][:channel]) end |
.process_response(response_hash) ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/isomorfeus/transport/client_processor.rb', line 22 def self.process_response(response_hash) response_hash[:response][:agent_ids].keys.each do |agent_id| agent = Isomorfeus::Transport::RequestAgent.get(agent_id) if agent && !agent.promise.realized? agent.full_response = response_hash agent.response = response_hash[:response][:agent_ids][agent_id] agent.promise.resolve(agent) end end end |