Skip to content

A minimalistic Go library for dealing with Asterisk Manager Interface

License

Notifications You must be signed in to change notification settings

pooladkhay/goAmi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

goAmi

A minimalistic Go library for dealing with Asterisk Manager Interface.

Installation

go get -u github.com/pooladkhay/goAmi

Usage

package main

import (
	"fmt"

	amiClient "github.com/pooladkhay/goAmi"
)

func main() {
	client := &amiClient.Opts{
		Address:  "ASTERISK_ADDR",
		Port:     "AMI_PORT",
		Username: "AMI_USERNAME",
		Secret:   "AMI_PASSWORD",

		PingInterval:      5,
		PongTimeout:       20,
		ReconnectInterval: 2,

		EventsToListen: []string{"All"},
		EventHandler:   eventHandler,
	}

	client.Connect()
	defer client.StartListening()

	if client.Connected {
		// example sending an action
		client.SendAction("Action:PJSIPShowEndpoints")
	}
}

// eventHandler will receive events as map[string]string which later can be filtered accordingly.
func eventHandler(event map[string]string) {
	if event["Event"] != "" {
		fmt.Println(event)
	}
}

Contributing

Pull requests are welcomed. For major changes, please open an issue first to discuss what you would like to change.

License

MIT

About

A minimalistic Go library for dealing with Asterisk Manager Interface

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages