Skip to content

adhearsion-drb is an Adhearsion Plugin providing DRb connectivity. It allows third party ruby clients to connect to an Adhearsion instance for RPC.

License

Notifications You must be signed in to change notification settings

adhearsion/adhearsion-drb

Repository files navigation

adhearsion-drb Build Status

adhearsion-drb is an Adhearsion Plugin providing DRb connectivity. It allows third party ruby clients to connect to an Adhearsion instance for RPC.

Requirements

  • Adhearsion 2.0+

Install

Add adhearsion-drb to your Adhearsion app's Gemfile.

Configuration

In your Adhearsion app configuration file, add the following values:

Adhearsion.config[:adhearsion_drb] do |config|
  config.host = "DRb service host"
  config.port = "DRB service port".to_i
  config.acl.allow = ["127.0.0.1"] # list of allowed IPs (optional)
  config.acl.deny = [] # list of denied IPs (optional)
  config.shared_object = some_shared_object
end

The shared_object in the config is the endpoint to which a 3rd-party client will be bound on connection. The most basic scenario looks something like this:

class DrbEndpoint
  def foo
    :bar
  end
end

Adhearsion.config.adhearsion_drb.shared_object = DrbEndpoint.new

with the following client:

require 'drb'
adhearsion_api = DRbObject.new_with_uri 'druby://localhost:9050'
p adhearsion_api.foo

When the Adhearsion application is running, and the client script runs, it should print :foo to stdout.

A more useful example to return the number of active calls:

class DrbEndpoint
  def call_count
    Adhearsion.active_calls.count
  end
end

Or to trigger an outbound call:

class DrbEndpoint
  def place_call(number, provider)
    call = Adhearsion::OutboundCall.originate "SIP/#{number}@#{provider}", controller: FooController
    call.id
  end
end

NB: Be careful not to define #call on your shared object, else it will be evaluated by the config system incorrectly.

Author

Original author: Juan de Bravo

Links

Note on Patches/Pull Requests

  • Fork the project.
  • Make your feature addition or bug fix.
  • Add tests for it. This is important so I don't break it in a future version unintentionally.
  • Commit, do not mess with rakefile, version, or history.
    • If you want to have your own version, that is fine but bump version in a commit by itself so I can ignore when I pull
  • Send me a pull request. Bonus points for topic branches.

Copyright

Copyright (C) 2012 Adhearsion Foundation Inc. Released under the MIT License - Check License file

About

adhearsion-drb is an Adhearsion Plugin providing DRb connectivity. It allows third party ruby clients to connect to an Adhearsion instance for RPC.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages