Created
November 11, 2016 18:57
-
-
Save Ulexus/28c023cf86cd6b93416bd09d9ad2b18a to your computer and use it in GitHub Desktop.
Bridge onsolo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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