Esempio n. 1
0
func main() {
	socket, err := ami.NewSocket("127.0.0.1:5038")
	if err != nil {
		fmt.Printf("socket error: %v\n", err)
		return
	}
	if _, err := ami.Connect(socket); err != nil {
		return
	}
	//Login
	uuid, _ := ami.GetUUID()
	if err := ami.Login(socket, "admin", "admin", "Off", uuid); err != nil {
		log.Fatalf("login error (%v)\n", err)
	}
	defer ami.Logoff(socket, uuid)
	fmt.Printf("login ok!\n")

	//List All SIPPeers
	peers, err := ami.SIPPeers(socket, uuid)
	if err != nil {
		log.Fatalf("sip peers error: %v\n", err)
	}
	for _, peer := range peers {
		message, err := ami.SIPShowPeer(socket, uuid, peer.Get("ObjectName"))
		if err != nil {
			log.Fatalf("sip show peer error: %v\n", err)
		}
		log.Printf("message: [%q]\n", message)
	}
}
Esempio n. 2
0
func main() {
	socket, err := ami.NewSocket("127.0.0.1:5038")
	if err != nil {
		fmt.Printf("socket error: %v\n", err)
		return
	}
	if _, err := ami.Connect(socket); err != nil {
		return
	}
	//Login
	uuid, _ := ami.GetUUID()
	if err := ami.Login(socket, "admin", "admin", "system,call,all,user", uuid); err != nil {
		log.Fatalf("login error (%v)\n", err)
	}
	defer ami.Logoff(socket, uuid)
	fmt.Printf("login ok!\n")

	//Events
	for {
		events, err := ami.Events(socket)
		if err != nil {
			fmt.Printf("events error (%v)\n", err)
			return
		}
		fmt.Printf("recv event: %v\n", events)
	}
}
Esempio n. 3
0
func main() {
	socket, err := ami.NewSocket("127.0.0.1:5038")
	if err != nil {
		fmt.Printf("socket error: %v\n", err)
		return
	}
	if _, err := ami.Connect(socket); err != nil {
		return
	}
	//Login
	uuid, _ := ami.GetUUID()
	if err := ami.Login(socket, "admin", "admin", "Off", uuid); err != nil {
		log.Fatalf("login error (%v)\n", err)
	}
	defer ami.Logoff(socket, uuid)
	fmt.Printf("login ok!\n")

	data := ami.KhompSMSData{
		Device:       "b0",
		Destination:  "4899893791",
		Confirmation: true,
		Message:      "hey ho, let's go",
	}
	s, err := ami.KSendSMS(socket, uuid, data)
	if err != nil {
		fmt.Printf("sms sms error\n", err)
	}
	fmt.Printf("response: [%v]\n", s)
}
Esempio n. 4
0
func main() {
	socket, err := ami.NewSocket("127.0.0.1:5038")
	if err != nil {
		fmt.Printf("socket error: %v\n", err)
		return
	}
	if _, err := ami.Connect(socket); err != nil {
		return
	}
	var ret bool

	//Login
	uuid, _ := ami.GetUUID()
	ret, err = ami.Login(socket, "admin", "admin", "Off", uuid)
	if err != nil || ret == false {
		fmt.Printf("login error (%v)\n", err)
		return
	}
	fmt.Printf("login ok!\n")

	//Logoff
	fmt.Printf("logoff\n")
	ret, err = ami.Logoff(socket, uuid)
	if err != nil || ret == false {
		fmt.Printf("logoff error: (%v)\n", err)
		return
	}
	fmt.Printf("goodbye !\n")
}
Esempio n. 5
0
File: sms.go Progetto: wy3148/goami
func main() {
	socket, err := ami.NewSocket("127.0.0.1:5038")
	if err != nil {
		fmt.Printf("socket error: %v\n", err)
		return
	}
	if _, err := ami.Connect(socket); err != nil {
		return
	}
	var ret bool

	//Login
	uuid, _ := ami.GetUUID()
	ret, err = ami.Login(socket, "admin", "admin", "Off", uuid)
	if err != nil || ret == false {
		fmt.Printf("login error (%v)\n", err)
		return
	}
	fmt.Printf("login ok!\n")

	data := ami.KhompSMSData{
		Device:       "b0",
		Destination:  "4899893791",
		Confirmation: true,
		Message:      "hey ho, let's go",
	}

	//SendSMS
	//	func KSendSMS(socket *Socket, actionID string, data KhompSMSData) (map[string]string, error) {
	//
	s, err := ami.KSendSMS(socket, uuid, data)
	if err != nil {
		fmt.Printf("sms sms error\n", err)
	}
	fmt.Printf("response: [%v]\n", s)

	//Logoff
	fmt.Printf("logoff\n")
	ret, err = ami.Logoff(socket, uuid)
	if err != nil || ret == false {
		fmt.Printf("logoff error: (%v)\n", err)
		return
	}
	fmt.Printf("goodbye !\n")
}
Esempio n. 6
0
func main() {
	socket, err := ami.NewSocket("127.0.0.1:5038")
	if err != nil {
		fmt.Printf("socket error: %v\n", err)
		return
	}
	if _, err := ami.Connect(socket); err != nil {
		return
	}
	var ret bool

	//Login
	uuid, _ := ami.GetUUID()
	ret, err = ami.Login(socket, "admin", "admin", "Off", uuid)
	if err != nil || ret == false {
		fmt.Printf("login error (%v)\n", err)
		return
	}
	fmt.Printf("login ok!\n")

	//List All SIPPeers
	list, _ := ami.SIPpeers(socket, uuid)
	if len(list) > 0 {
		for _, m := range list {
			message, _ := ami.SIPshowpeer(socket, uuid, m["ObjectName"])
			for k, v := range message {
				fmt.Printf("%s : %q\n", k, v)
			}
		}
	}
	fmt.Printf("\n")

	//Logoff
	fmt.Printf("logoff\n")
	ret, err = ami.Logoff(socket, uuid)
	if err != nil || ret == false {
		fmt.Printf("logoff error: (%v)\n", err)
		return
	}
	fmt.Printf("goodbye !\n")
}
Esempio n. 7
0
func main() {
	socket, err := ami.NewSocket("127.0.0.1:5038")
	if err != nil {
		log.Fatalf("socket error: %v\n", err)
	}
	if _, err := ami.Connect(socket); err != nil {
		return
	}
	//Login
	uuid, _ := ami.GetUUID()
	if err := ami.Login(socket, "admin", "admin", "Off", uuid); err != nil {
		log.Fatalf("login error (%v)\n", err)
	}
	fmt.Printf("login ok!\n")

	//Logoff
	fmt.Printf("logoff\n")
	if err := ami.Logoff(socket, uuid); err != nil {
		log.Fatalf("logoff error: (%v)\n", err)
	}
	fmt.Printf("goodbye !\n")
}
Esempio n. 8
0
func main() {
	socket, err := ami.NewSocket("127.0.0.1:5038")
	if err != nil {
		fmt.Printf("socket error: %v\n", err)
		return
	}
	if _, err := ami.Connect(socket); err != nil {
		return
	}
	var ret bool

	//Login
	uuid, _ := ami.GetUUID()
	ret, err = ami.Login(socket, "admin", "admin", "system,call,all,user", uuid)
	if err != nil || ret == false {
		fmt.Printf("login error (%v)\n", err)
		return
	}
	fmt.Printf("login ok!\n")

	//Events
	for {
		events, err := ami.GetEvents(socket)
		if err != nil {
			fmt.Printf("events error (%v)\n", err)
			return
		}
		fmt.Printf("recv event: %v\n", events)
	}

	//Logoff
	fmt.Printf("logoff\n")
	ret, err = ami.Logoff(socket, uuid)
	if err != nil || ret == false {
		fmt.Printf("logoff error: (%v)\n", err)
		return
	}
	fmt.Printf("goodbye !\n")
}