All Projects → bit4bit → gami

bit4bit / gami

Licence: MIT license
GO - Asterisk AMI Interface

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to gami

cache
Simple and easy go cache micro framework
Stars: ✭ 12 (-61.29%)
Mutual labels:  interface
nuada-cli
Nuada CLI was designed to improve your development experience by using ExpressJS and Mongoose tools.
Stars: ✭ 19 (-38.71%)
Mutual labels:  interface
ElvUI
ElvUI for World of Warcraft - Vanilla (1.12.1)
Stars: ✭ 67 (+116.13%)
Mutual labels:  interface
dualFace
dualFace: Two-Stage Drawing Guidance for Freehand Portrait Sketching (CVMJ)
Stars: ✭ 46 (+48.39%)
Mutual labels:  interface
nxdk-rdt
Remote Dev Tool is a tool to remote control an Xbox using memory access and RPC
Stars: ✭ 23 (-25.81%)
Mutual labels:  interface
mainsail
Mainsail is the popular web interface for Klipper
Stars: ✭ 960 (+2996.77%)
Mutual labels:  interface
MathematicaStan
A Mathematica package to interact with CmdStan
Stars: ✭ 27 (-12.9%)
Mutual labels:  interface
Unity-Interface-Support
A simple implementation which allows for interface-type fields to be accepted in the Unity inspector.
Stars: ✭ 45 (+45.16%)
Mutual labels:  interface
Server
The whir.io chat server.
Stars: ✭ 15 (-51.61%)
Mutual labels:  interface
Cemu-UI
A user interface for the Wii U emulator, Cemu
Stars: ✭ 21 (-32.26%)
Mutual labels:  interface
Unity-SerializeReferenceExtensions
Provide popup to specify the type of the field serialized by the [SerializeReference] attribute in the inspector.
Stars: ✭ 255 (+722.58%)
Mutual labels:  interface
scaleway-csi
Container Storage Interface (CSI) Driver for https://www.scaleway.com/block-storage/
Stars: ✭ 52 (+67.74%)
Mutual labels:  interface
qweechat
Qt remote GUI for WeeChat.
Stars: ✭ 56 (+80.65%)
Mutual labels:  interface
sassy-css
Learn UI Design, CSS, SASS by completing interesting tasks.
Stars: ✭ 16 (-48.39%)
Mutual labels:  interface
Java-Programs
Java Practiced Problems including concepts of OOPS, Interface, String , Collection.
Stars: ✭ 51 (+64.52%)
Mutual labels:  interface
rkdb
R client for kdb+
Stars: ✭ 37 (+19.35%)
Mutual labels:  interface
crab
JavaScript library for building user interfaces with Custom Elements, Shadow DOM and React like API
Stars: ✭ 22 (-29.03%)
Mutual labels:  interface
webpack-ui
The Graphical User Interface for webpack
Stars: ✭ 45 (+45.16%)
Mutual labels:  interface
node-qemu-server
Free GUI / Frontend / Management tool for simple setup, configure and control virtual machines (qemu / kvm) within your HTML5 Webbrowser. Virtualization with Node.js / Currently under complete rewrite.
Stars: ✭ 41 (+32.26%)
Mutual labels:  interface
GCPEditorPro
Amazingly fast and simple ground control points interface. ◎
Stars: ✭ 33 (+6.45%)
Mutual labels:  interface

GAMI

GO - Asterisk AMI Interface

communicate with the Asterisk AMI, Actions and Events.

Example connecting to Asterisk and Send Action get Events.

package main
import (
	"log"
	"github.com/bit4bit/gami"
	"github.com/bit4bit/gami/event"
	"time"
)

func main() {
	ami, err := gami.Dial("127.0.0.1:5038")
	if err != nil {
		log.Fatal(err)
	}
	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 _, errPing := ami.Action("Ping", nil); errPing != nil {
		log.Fatal(errPing)
	}
	
	//async actions
	rsPing, rsErr := ami.AsyncAction("Ping", gami.Params{"ActionID": "pingo"})
	if rsErr != nil {
		log.Fatal(rsErr)
	}
						
	if _, err := ami.Action("Events", gami.Params{"EventMask":"on"}); err != nil {
		log.Fatal(err)
	}
	
	log.Println("ping:", <-rsPing)
	

}

###TLS SUPPORT In order to use TLS connection to manager interface you could Dial with additional parameters

//without TLS
ami, err := gami.Dial("127.0.0.1:5038")

//if certificate is trusted
ami, err := gami.Dial("127.0.0.1:5039", gami.UseTLS)

//if self signed certificate
ami, err := gami.Dial("127.0.0.1:5039", gami.UseTLS, gami.UnsecureTLS)

//if custom tls configuration
ami, err := gami.Dial("127.0.0.1:5039", gami.UseTLSConfig(&tls.Config{}))

WARNING: Only Asterisk >=1.6 supports TLS connection to AMI and it needs additional configuration(follow the Asterisk AMI configuration documentation)

CURRENT EVENT TYPES

The events use documentation and struct from PAMI.

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

EVENT ID TYPE TEST
Newchannel YES
Newexten YES
Newstate YES
Dial YES
ExtensionStatus YES
Hangup YES
PeerStatus YES
PeerEntry YES
VarSet YES
AgentLogin YES
Agents YES
AgentLogoff YES
AgentConnect YES
RTPReceiverStats YES
RTPSenderStats YES
Bridge YES
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].