Console

When starting an Adhearsion app in the foreground (ahn start), a console is provided to interact with the application and its calls. It is possible to take control of currently active calls, execute commands on them, make outbound calls, etc.

Taking a currently active call

When a call has one or more controllers running against it, it is possible to sieze control of the call using the console #take method. You may either supply the call's ID or the call object itself, or supply no parameters and be presented with a list of calls to choose from. If there is only one active call, you will not be presented with a choice.


AHN> take
Please choose a call:
 # (inbound/outbound) details
0: (i) 5vg6dkqc-lx7-2zujv5xbe7zd from sip:rwkdjpmu@192.168.1.74 to sip:usera@127.0.0.1
1: (i) 5vg6dkqc-lx7-2n2wgrzooard from sip:rwkdjpmu@192.168.1.74 to sip:usera@127.0.0.1
 #> 1
AHN<5vg6dkqc-lx7-2n2wgrzooard>

Once you have control of a call, other controllers will stop executing (at the next time they try to run a command against the call) and you may use any CallController methods you like. The console itself is just an interactive CallController.

Routing calls directly to the console

It is not currently possible to route calls directly to the console, but this feature is coming soon. In the meantime, the following hack is a potential solution, preventing the router from hanging up the call so that you can grab control in the console:

Adhearsion.routes do
  openended do
    route 'ConsoleCatch' do
      logger.info "Call #{call.id} waiting..."
    end
  end
end

Making outbound calls

The current preferred method of making an outbound call is like so:


AHN> Adhearsion::OutboundCall.originate 'sip:arabbit@mojolingo.com', from: 'sip:foo@bar.com'

The call will pass through the router in the same way as an incoming call.

Back to Installation Continue to Call Controllers
blog comments powered by Disqus