Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
This repository was archived by the owner on Jan 4, 2019. It is now read-only.
/gamiPublic archive

GO - Asterisk AMI Interface

License

NotificationsYou must be signed in to change notification settings

bit4bit/gami

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

58 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GO - Asterisk AMI Interface

communicate with the Asterisk AMI, Actions and Events.

Example connecting to Asterisk and Send Action get Events.

package mainimport ("log""github.com/bit4bit/gami""github.com/bit4bit/gami/event""time")funcmain() {ami,err:=gami.Dial("127.0.0.1:5038")iferr!=nil {log.Fatal(err)}ami.Run()deferami.Close()//install managergofunc() {for {select {//handle network errorscaseerr:=<-ami.NetError:log.Println("Network Error:",err)//try new connection every second<-time.After(time.Second)iferr:=ami.Reconnect();err==nil {//call start actionsami.Action("Events", gami.Params{"EventMask":"on"})}caseerr:=<-ami.Error:log.Println("error:",err)//wait events and processcaseev:=<-ami.Events:log.Println("Event Detect: %v",*ev)//if want type of eventslog.Println("EventType:",event.New(ev))}}}()iferr:=ami.Login("admin","root");err!=nil {log.Fatal(err)}if_,errPing:=ami.Action("Ping",nil);errPing!=nil {log.Fatal(errPing)}//async actionsrsPing,rsErr:=ami.AsyncAction("Ping", gami.Params{"ActionID":"pingo"})ifrsErr!=nil {log.Fatal(rsErr)}if_,err:=ami.Action("Events", gami.Params{"EventMask":"on"});err!=nil {log.Fatal(err)}log.Println("ping:",<-rsPing)}

###TLS SUPPORTIn order to use TLS connection to manager interface you couldDial with additional parameters

//without TLSami,err:=gami.Dial("127.0.0.1:5038")//if certificate is trustedami,err:=gami.Dial("127.0.0.1:5039",gami.UseTLS)//if self signed certificateami,err:=gami.Dial("127.0.0.1:5039",gami.UseTLS,gami.UnsecureTLS)//if custom tls configurationami,err:=gami.Dial("127.0.0.1:5039",gami.UseTLSConfig(&tls.Config{}))

WARNING:Only Asterisk >=1.6 supports TLS connection to AMI andit needs additional configuration(follow theAsterisk AMI configuration documentation)

CURRENT EVENT TYPES

The events use documentation and struct fromPAMI.

usebit4bit/gami/event.New() for get this struct from raw event

EVENT IDTYPE TEST
NewchannelYES
NewextenYES
NewstateYES
DialYES
ExtensionStatusYES
HangupYES
PeerStatusYES
PeerEntryYES
VarSetYES
AgentLoginYES
AgentsYES
AgentLogoffYES
AgentConnectYES
RTPReceiverStatsYES
RTPSenderStatsYES
BridgeYES

Releases

No releases published

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp