Documentation ¶
Overview ¶
Package gami provites primitives for interacting with Asterisk AMI
Basic Usage
ami, err := gami.Dial("127.0.0.1:5038") if err != nil { fmt.Print(err) os.Exit(1) } ami.Run() defer ami.Close() //install manager go func() { for { select { //handle network errors case err := <-ami.NetError: log.Println("Network Error:", err) //try new connection every second <-time.After(time.Second) if err := ami.Reconnect(); err == nil { //call start actions ami.Action("Events", gami.Params{"EventMask": "on"}) } case err := <-ami.Error: log.Println("error:", err) //wait events and process case ev := <-ami.Events: log.Println("Event Detect: %v", *ev) //if want type of events log.Println("EventType:", event.New(ev)) } } }() if err := ami.Login("admin", "root"); err != nil { log.Fatal(err) } if rs, err = ami.Action("Ping", nil); err == nil { log.Fatal(rs) } //or with can do async pingResp, pingErr := ami.AsyncAction("Ping", gami.Params{"ActionID": "miping"}) if pingErr != nil { log.Fatal(pingErr) } if rs, err = ami.Action("Events", ami.Params{"EventMask":"on"}); err != nil { fmt.Print(err) } log.Println("future ping:", <-pingResp)
Index ¶
- Variables
- func UnsecureTLS(c *AMIClient)
- func UseTLS(c *AMIClient)
- func UseTLSConfig(config *tls.Config) func(*AMIClient)
- type AMIClient
- func (client *AMIClient) Action(action string, params Params) (*AMIResponse, error)
- func (client *AMIClient) AsyncAction(action string, params Params) (<-chan *AMIResponse, error)
- func (client *AMIClient) Close()
- func (client *AMIClient) Login(username, password string) error
- func (client *AMIClient) NewConn() (err error)
- func (client *AMIClient) Reconnect() error
- func (client *AMIClient) Run()
- type AMIEvent
- type AMIResponse
- type Params
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrNotAMI = errors.New("Server not AMI interface")
Raise when not response expected protocol AMI
Functions ¶
func UnsecureTLS ¶
func UnsecureTLS(c *AMIClient)
func UseTLSConfig ¶
Types ¶
type AMIClient ¶
type AMIClient struct { // Events for client parse Events chan *AMIEvent // Error Raise on logic Error chan error //NetError a network error NetError chan error // contains filtered or unexported fields }
AMIClient a connection to AMI server
func (*AMIClient) Action ¶
func (client *AMIClient) Action(action string, params Params) (*AMIResponse, error)
Action send with params
func (*AMIClient) AsyncAction ¶
func (client *AMIClient) AsyncAction(action string, params Params) (<-chan *AMIResponse, error)
AsyncAction return chan for wait response of action with parameter *ActionID* this can be helpful for massive actions,
type AMIEvent ¶
type AMIEvent struct { //Identification of event Event: xxxx ID string Privilege []string // Params of arguments received Params map[string]string }
AMIEvent it's a representation of Event readed
type AMIResponse ¶
AMIResponse from action
Directories ¶
Path | Synopsis |
---|---|
Package event for AMI Package event for AMI Package event for AMI Package event for AMI Package event for AMI Package event for AMI Package event decoder This Build Type of Event received Package event for AMI Package event for AMI Package event for AMI Package event for AMI Package event for AMI Package event for AMI Package event for AMI Package event for AMI Package event for AMI Package event for AMI
|
Package event for AMI Package event for AMI Package event for AMI Package event for AMI Package event for AMI Package event for AMI Package event decoder This Build Type of Event received Package event for AMI Package event for AMI Package event for AMI Package event for AMI Package event for AMI Package event for AMI Package event for AMI Package event for AMI Package event for AMI Package event for AMI |
Click to show internal directories.
Click to hide internal directories.