Example #1
0
func (originator *callOriginator) processTestCall() {
	c, err := net.Dial("tcp", fmt.Sprintf("%s:%d", originator.Addr, originator.Port))

	if err != nil {
		originator.resultTestCall <- err
		return
	}

	defer c.Close()

	g := gami.NewAsterisk(&c, nil)

	err = g.Login(originator.Username, originator.Password)

	if err != nil {
		originator.resultTestCall <- err
		return
	}

	ch := "Local/testcall@app-alive-test"

	o := gami.NewOriginateApp(ch, "System", "touch /tmp/vorimport")

	cb := func(m gami.Message) {
		fmt.Println(m)
	}
	err = g.Originate(o, nil, &cb)

	if err != nil {
		originator.resultTestCall <- err
		return
	}
	originator.resultTestCall <- nil

}
Example #2
0
File: main.go Project: vyachin/gami
func originate(a *gami.Asterisk) {

	fmt.Println("Enter channel: ")
	var ch string
	fmt.Scanf("%s\n", &ch)

	o := gami.NewOriginateApp(ch, "playback", "hello-world")
	var err error

	if !debug {
		cb := func(m gami.Message) {
			fmt.Println(m)
		}
		err = a.Originate(o, nil, &cb)
	} else {
		err = a.Originate(o, nil, nil)
	}

	if err != nil {
		log.Fatal(err)
	}
}