Skip to content

Instantly share code, notes, and snippets.

@Ulexus
Created November 11, 2016 18:57
Show Gist options
  • Save Ulexus/28c023cf86cd6b93416bd09d9ad2b18a to your computer and use it in GitHub Desktop.
Save Ulexus/28c023cf86cd6b93416bd09d9ad2b18a to your computer and use it in GitHub Desktop.
Bridge onsolo
func (a app) wait(ctx context.Context) stateFn {
brSub := a.Bridge.Subscribe(ari.Events.ChannelLeftBridge)
defer brSub.Cancel()
err := a.Bridge.AddChannel(a.channel)
if err != nil {
a.log.Error("Failed to add caller to bridge", "error", err)
return a.failure
}
// Wait for bridge events
for {
select {
case ctx.Done():
return nil
case e := <-brSub.Events():
data, err := a.Bridge.Data()
if err != nil {
a.log.Error("Failed to get bridge data", "error", err)
return a.failure
}
if len(data.ChannelIDs) < 2 {
a.log.Debug("Bridge soloed")
return nil
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment