Adhearsion now has an
RPC implementation that supports several technologies out of the box for connecting an external process to Adhearsion. These technologies include a
RESTful component, a
STOMP queue
component, as well as support for
Distributed Ruby (DRb). DRb is a distributed object system that allows another process to invoke methods on a remote object over
TCP, similar to the Java
RMI and included in the
Ruby standard library. With a DRb connection you may have inter-process communication between two Ruby processes on the same server, or between two processes distributed geographically via the internet.
By default an
ami_remote component is enabled in Adhearsion that exposes the
Asterisk Manager Interface Class via DRb. With this, you may initiate outbound dials from a
Rails app by simply doing the following:
[sourcecode language='ruby']
require 'drb'
Adhearsion = DRbObject.new_with_uri "druby://localhost:9050"
Adhearsion.call_into_context("SIP/
17475551212@proxy01.sipphone.com", "play_message_context")
[/sourcecode]
This example would initiate a call to a
SIPPhone user and once connected could play a message to the person dialed.
Using an
Adhearsion Component you may also add additional RPC methods. For example:
[sourcecode language='ruby']
methods_for :rpc do
def method_for_remote_access(options)
#some code here
end
end
[/sourcecode]
This code would create a method that could be accessed via DRb or any of the other supported RPC transports from your remote process.
The Adhearsion RPC support is a powerful capability of the framework that allows for virtually any application to access Adhearsion capabilities. For additional information visit the
DRb and
Components pages on the
Adhearsion Wiki.