ER

emilianodellacasa/ruby-asterisk

Developer tools

이 페이지는 AI로 자동 번역되었습니다. 기술적인 세부 사항은 원문을 확인하세요. 원문 보기

76 stars 품질 55 트렌드 18MIT

Ruby의 Asterisk Manager 인터페이스

개요

Asterisk PBX를 위한 Ruby 클라이언트는 3개의 공용영역을 덮습니다: - - 런타임 의존성: async ~> 2.0, faraday >= 1.0, websocket-driver ~> 0.8 : Async Fiber Scheduler가 요구되는 IO#timeout shim는 AGI 모듈이 로드될 때 자동으로 적용됩니다. 모든 AMI 명령은 RubyAsterisk를 반환합니다.:AMI:: 즉시 약속 — 블록입니다. 응답을 기다리기 위해 .value (timeout)를 호출하십시오: RuntimeError로 모든 권총 약속을 거부합니다. RubyAsterisk의 상태 값::DESCRIPTIVE STATUS: -1 Extension not found · 0 Idle · 1 In use · 2 Busy · 3 Unavailable · 4 Ringing · 5 On Hold DescriptiveStatus는 해당 맵의 상태에만 추가됩니다. 다른 값은 nil을 산출합니다. 구조 데이터 파싱 명령 (PARSE DATA) : CoreShowChannels, ParkedCalls, Originate, MeetMeList, ConfbridgeListRooms, ConfbridgeList, Status, ExtensionState, DeviceStateList, SKINNYdevice, SKINNYlines, QueuePause, Pong, Events, SIPpeers, SIPshowpeer.

개요(AI 번역)

Asterisk PBX를 위한 Ruby 클라이언트는 3개의 공용영역을 덮습니다:

| 인터페이스 | 사용 케이스 | 입장 | 통화 모델 | |—|—|||||| | AMI | TCP 명령/출구 채널 | RubyAsterisk::AMI::Client | 실 + 약속(비 차단) | | ARI HTTP | REST 컨트롤 API | RubyAsterisk::ARI::Client | 동시대응 | | ARI WebSocket | 실시간 이벤트 스트림 | RubyAsterisk::ARI::WebSocket | websocket-driver + Threads | |AGI / FastAGI | 가공 다이얼 플랜 논리 | [T3] | Async + Fiber |

요구 사항

  • 루비 ≥ 3.1
  • 런타임 의존성: async ~> 2.0, faraday >= 1.0, websocket-driver ~> 0.8]

Ruby 3.1 참고: Async Fiber Scheduler가 요구되는 IO#timeout shim은 AGI 모듈이 로드될 때 자동으로 적용됩니다.

설치

AMI — Asterisk 관리자 인터페이스

초기화 및 연결

# Promise 모델

모든 AMI 명령은 RubyAsterisk::AMI::Promise]을 즉시 반환합니다. ** 블록이 아닙니다. .value(timeout)] Response]를 기다립니다:

disconnect] RuntimeError]와 함께 약속을 거부합니다.

로그인 / 로그인

시스템 명령

채널 명령

이 페이지는 AI로 자동 번역되었습니다. 기술적인 세부 사항은 원문을 확인하세요.

README

원문 README의 일부입니다. 원문 보기.

ruby-asterisk

A Ruby client for Asterisk PBX covering three interfaces:

Interface Use case Entry point Concurrency model
AMI TCP command/event channel RubyAsterisk::AMI::Client Threads + Promise (non-blocking)
ARI HTTP REST control API RubyAsterisk::ARI::Client Synchronous (Faraday)
ARI WebSocket Real-time event stream RubyAsterisk::ARI::WebSocket websocket-driver + Threads
AGI / FastAGI In-process dialplan logic RubyAsterisk::AGI::Server Async + Fibers

Requirements

  • Ruby ≥ 3.1
  • Runtime dependencies: async ~> 2.0, faraday >= 1.0, websocket-driver ~> 0.8

Ruby 3.1 note: the IO#timeout shim required by the Async Fiber scheduler is applied automatically when the AGI module is loaded — no action needed.

Installation

gem 'ruby-asterisk'
bundle install

AMI — Asterisk Manager Interface

Initialize and connect

require 'ruby-asterisk'

ami = RubyAsterisk::AMI::Client.new(host: '192.168.1.1', port: 5038)
ami.connect

The Promise model

Every AMI command returns a RubyAsterisk::AMI::Promise immediately — it does not block. Call .value(timeout) to wait for the Response:

promise  = ami.ping          # returns immediately
response = promise.value     # blocks up to 5 s (default)
response = promise.value(10) # custom timeout in seconds

puts response.success        # => true
puts response.message        # => "Pong"
puts response.action_id      # => "lk3m0p..."
puts response.data           # => structured Hash or Array depending on command
puts response.raw_response   # => raw AMI text

# On timeout:
begin
  response = promise.value(2)
rescue Timeout::Error => e
  puts e.message
end

disconnect rejects all pending promises with a RuntimeError.

Login / Logoff

ami.login(username: 'mark', secret: 'mysecret').value
ami.logoff.value

System commands

ami.ping.value
ami.command('core show channels').value
ami.wait_event(timeout: -1).value     # -1 = wait forever: .value blocks until an event arrives
ami.wait_event(timeout: 30).value     # bounded wait; .value gives up after 30 s
ami.event_mask('on').value            # enable event delivery on this connection
ami.parked_calls.value
ami.device_state_list.value
ami.skinny_devices.value
ami.skinny_lines.value

Channel commands

ami.core_show_channels.value
ami.status.value                      # all channels
ami.status(channel: 'SIP/alice-001').value

# Originate: channel, context, callee, priority
ami.originate('SIP/9100', 'OUTGOING', '123456', '1',
              caller_id: 'Alice',
              variable: 'var1=12,var2=99',
              timeout: 30_000,
GitHub에서 전체 README 보기

추천 도구

다른 키워드를 입력하거나 필터를 제거해 보세요.

설치

npx skillfish add emilianodellacasa/ruby-asterisk
MCP 초보자라면? mcpskill.org 가이드부터 시작하세요 →