def dial(to, options = {})
      options = options.dup
      options[:to] = to
      if options[:timeout]
        wait_timeout = options[:timeout]
        options[:timeout] = options[:timeout] * 1000
      else
        wait_timeout = 60
      end

      uri = client.new_call_uri
      options[:uri] = uri

      @dial_command = Adhearsion::Rayo::Command::Dial.new(options)

      ref = Adhearsion::Rayo::Ref.new uri: uri
      @transport = ref.scheme
      @id = ref.call_id
      @domain = ref.domain

      Adhearsion.active_calls << current_actor

      write_and_await_response(@dial_command, wait_timeout, true).tap do |dial_command|
        @start_time = dial_command.timestamp.to_time
        if @dial_command.uri != self.uri
          logger.warn "Requested call URI (#{uri}) was not respected. Tracking by new URI #{self.uri}. This might cause a race in event handling, please upgrade your Rayo server."
          Adhearsion.active_calls << current_actor
          Adhearsion.active_calls.delete(@id)
        end
        Adhearsion::Events.trigger :call_dialed, current_actor
      end
    rescue
      clear_from_active_calls
      raise
    end
def dial(to, options = {})
      options = options.dup
      options[:to] = to
      if options[:timeout]
        wait_timeout = options[:timeout]
        options[:timeout] = options[:timeout] * 1000
      else
        wait_timeout = 60
      end

      uri = client.new_call_uri
      options[:uri] = uri

      @dial_command = Adhearsion::Rayo::Command::Dial.new(options)

      ref = Adhearsion::Rayo::Ref.new uri: uri
      @transport = ref.scheme
      @id = ref.call_id
      @domain = ref.domain

      Adhearsion.active_calls << current_actor

      write_and_await_response(@dial_command, wait_timeout, true).tap do |dial_command|
        @start_time = dial_command.timestamp.to_time
        if @dial_command.uri != self.uri
          logger.warn "Requested call URI (#{uri}) was not respected. Tracking by new URI #{self.uri}. This might cause a race in event handling, please upgrade your Rayo server."
          Adhearsion.active_calls << current_actor
          Adhearsion.active_calls.delete(@id)
        end
        Adhearsion::Events.trigger :call_dialed, current_actor
      end
    rescue
      clear_from_active_calls
      raise
    end
Dial out an existing outbound call

 @param [String] to the URI of the party to dial
 @param [Hash] options modifier options
 @option options [String, Optional] :from what to set the Caller ID to
 @option options [Integer, Optional] :timeout in seconds
 @option options [Hash, Optional] :headers SIP headers to attach to
   the new call.