CyCoreSystems / ari

Golang Asterisk REST Interface (ARI) library
Apache License 2.0
191 stars 73 forks source link

_examples/play h.Hangup() don't work #127

Open remotejob opened 3 years ago

remotejob commented 3 years ago

Asterisk 18.0.0 go version go1.15.6

it's a play file but don't make h.Hangup() ??

`func app(ctx context.Context, h *ari.ChannelHandle) { defer h.Hangup()

ctx, cancel := context.WithCancel(ctx)
defer cancel()

log.Info("Running app", "channel", h.ID())

end := h.Subscribe(ari.Events.StasisEnd)
defer end.Cancel()

// End the app when the channel goes away
go func() {
    <-end.Events()
    cancel()
}()

if err := h.Answer(); err != nil {
    log.Error("failed to answer call", "error", err)
    return
}

if err := play.Play(ctx, h, play.URI("sound:tt-monkeys")).Err(); err != nil {
    log.Error("failed to play sound", "error", err)
    return
}

log.Info("completed playback")
// end.Cancel()
h.Hangup()
return

}`

raszia commented 3 years ago

Did you find any solution? @remotejob