asterisk-ami.cr

Asterisk's AMI wrapper for Crystal Lang

asterisk-ami

TODO: Write a description here

Installation

  1. Add the dependency to your shard.yml:

    dependencies:
      asterisk-ami:
        github: bit4bit/asterisk-ami
    
  2. Run shards install

Usage

require "json"
require "asterisk-ami"

conn = Asterisk::Ami::Inbound.new("localhost", 5038, "demo", "demo")
if !conn.connect(1.second)
  raise "fails authenticate to #{host}"
end

# example action and wait for response
puts conn.request(Asterisk::Action.new(
  "Ping",
  UUID.v4.hexstring
)
).inspect

events = Channel(Asterisk::Event).new(1024*16)
spawn name: "asterisk events" do
  conn.pull_events do |event|
    events.send(event)
  end
rescue ex
  STDERR.puts ex.inspect_with_backtrace
  exit 1
end

loop do
  event = events.receive
  if event.get("Event") == "Shutdown"
    STDERR.puts "asterisk shutdown"
    exit 1
  end

  puts event.message.to_json
end

Development

TODO: Write development instructions here

Contributing

  1. Fork it (https://github.com/your-github-user/asterisk-ami/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors

Repository

asterisk-ami.cr

Owner
Statistic
  • 1
  • 0
  • 0
  • 0
  • 0
  • 22 days ago
  • December 25, 2024
License

MIT License

Links
Synced at

Wed, 22 Jan 2025 02:15:41 GMT

Languages