def handle_event(event)
      if event.is_a?(Hash)
        if ["Push", "Request"].include?(event[:type])
          # Use next_tick to ensure that on main reactor thread
          # so that any data access is thread safe
          EM_S.next_tick do
            begin
              if (result = @dispatcher.dispatch(event_to_packet(event))) && event[:type] == "Request"
                @client.notify(result_to_event(result), [result.to])
              end
            rescue Dispatcher::DuplicateRequest
            rescue Exception => e
              ErrorTracker.log(self, "Failed sending response for <#{event[:uuid]}>", e)
            end
          end
        elsif event[:type] == "Result"
          if (data = event[:data]) && (result = data[:result]) && result.respond_to?(:non_delivery?) && result.non_delivery?
            Log.info("Non-delivery of event <#{data[:request_uuid]}>: #{result.content}")
          else
            ErrorTracker.log(self, "Unexpected Result event from #{event[:from]}: #{event.inspect}")
          end
        else
          ErrorTracker.log(self, "Unrecognized event type #{event[:type]} from #{event[:from]}")
        end
      else
        ErrorTracker.log(self, "Unrecognized event: #{event.class}")
      end
      nil
    end
def handle_event(event)
      if event.is_a?(Hash)
        if ["Push", "Request"].include?(event[:type])
          # Use next_tick to ensure that on main reactor thread
          # so that any data access is thread safe
          EM_S.next_tick do
            begin
              if (result = @dispatcher.dispatch(event_to_packet(event))) && event[:type] == "Request"
                @client.notify(result_to_event(result), [result.to])
              end
            rescue Dispatcher::DuplicateRequest
            rescue Exception => e
              ErrorTracker.log(self, "Failed sending response for <#{event[:uuid]}>", e)
            end
          end
        elsif event[:type] == "Result"
          if (data = event[:data]) && (result = data[:result]) && result.respond_to?(:non_delivery?) && result.non_delivery?
            Log.info("Non-delivery of event <#{data[:request_uuid]}>: #{result.content}")
          else
            ErrorTracker.log(self, "Unexpected Result event from #{event[:from]}: #{event.inspect}")
          end
        else
          ErrorTracker.log(self, "Unrecognized event type #{event[:type]} from #{event[:from]}")
        end
      else
        ErrorTracker.log(self, "Unrecognized event: #{event.class}")
      end
      nil
    end
Handle events received by this agent

 === Parameters
 event(Hash):: Event received

 === Return
 nil:: Always return nil indicating no response since handled separately via notify