func ping(a *gami.Asterisk) { m := gami.Message{"Action": "Ping"} cb := func(m gami.Message) { fmt.Println(m) } err := a.SendAction(m, &cb) if err != nil { log.Fatal(err) } }
func list(a *gami.Asterisk) { fmt.Println("Enter conference name: ") var conf string fmt.Scanf("%s\n", &conf) ml, err := a.GetConfbridgeList(conf) if err != nil { log.Fatal(err) } fmt.Println(ml) }
func toggleDebug(a *gami.Asterisk) { if debug { fmt.Println("Enabling debugging AMI events") dh := func(m gami.Message) { fmt.Println(m) } a.DefaultHandler(&dh) } else { fmt.Println("Disabling debugging AMI events") a.DefaultHandler(nil) } }
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) } }