def listen(routing_keys, &handler)
      raise ArgumentError, "Block missing" unless block_given?

      @event_uuids = nil
      @listen_interval = 0
      @listen_state = :choose
      @listen_failures = 0
      @connect_interval = CONNECT_INTERVAL
      @reconnect_interval = RECONNECT_INTERVAL

      listen_loop(routing_keys, &handler)
      true
    end
def listen(routing_keys, &handler)
      raise ArgumentError, "Block missing" unless block_given?

      @event_uuids = nil
      @listen_interval = 0
      @listen_state = :choose
      @listen_failures = 0
      @connect_interval = CONNECT_INTERVAL
      @reconnect_interval = RECONNECT_INTERVAL

      listen_loop(routing_keys, &handler)
      true
    end
Receive events via an HTTP WebSocket if available, otherwise via an HTTP long-polling

 @param [Array, NilClass] routing_keys for event sources of interest with nil meaning all

 @yield [event] required block called each time event received
 @yieldparam [Hash] event received

 @return [TrueClass] always true, although only returns when closing

 @raise [ArgumentError] block missing
 @raise [Exceptions::Unauthorized] authorization failed
 @raise [Exceptions::ConnectivityFailure] cannot connect to server, lost connection
   to it, or it is out of service or too busy to respond
 @raise [Exceptions::RetryableError] request failed but if retried may succeed
 @raise [Exceptions::Terminating] closing client and terminating service
 @raise [Exceptions::InternalServerError] internal error in server being accessed