Documentation ¶
Index ¶
- Constants
- Variables
- func MatchAny() func(*Options) error
- func MatchFunc(f func(string) (string, MatchResult)) func(*Options) error
- func MatchHash() func(*Options) error
- func MatchLen(length int) func(*Options) error
- func MatchLenOrTerminator(length int, terminator string) func(*Options) error
- func MatchTerminator(terminator string) func(*Options) error
- func PlaybackStartTimeout(timeout time.Duration) func(*Options) error
- func Replays(count int) func(*Options) error
- func URI(uri ...string) func(*Options) error
- type MatchResult
- type Options
- type Result
- type Status
Constants ¶
const AllDTMF = "0123456789ABCD*#"
AllDTMF is a string which contains all possible DTMF digits.
Variables ¶
var ( // DefaultPlaybackStartTimeout is the default amount of time to wait for a playback to start before declaring that the playback has failed. DefaultPlaybackStartTimeout = 2 * time.Second // DefaultMaxPlaybackTime is the default maximum amount of time any playback is allowed to run. If this time is exeeded, the playback will be cancelled. DefaultMaxPlaybackTime = 10 * time.Minute // DefaultFirstDigitTimeout is the default amount of time to wait, after the playback for all audio completes, for the first digit to be received. DefaultFirstDigitTimeout = 4 * time.Second // DefaultInterDigitTimeout is the maximum time to wait for additional // digits after the first is received. DefaultInterDigitTimeout = 3 * time.Second // DefaultOverallDigitTimeout is the default maximum time to wait for a // response, after the playback for all audio is complete, regardless of the // number of received digits or pattern matching. DefaultOverallDigitTimeout = 3 * time.Minute // DigitBufferSize is the number of digits stored in the received-digit // event buffer before further digit events are ignored. NOTE that digits // overflowing this buffer are still stored in the digits received buffer. // This only affects the digit _signaling_ buffer. DigitBufferSize = 20 )
var Logger = log15.New()
Logger defaults to a discard handler (null output). If you wish to enable logging, you can set your own handler like so:
ari.Logger.SetHandler(log15.StderrHandler)
Functions ¶
func MatchAny ¶
MatchAny indicates that the playback should be considered Matched and terminated if any DTMF digit is received during the playback or post-playback time.
func MatchFunc ¶
func MatchFunc(f func(string) (string, MatchResult)) func(*Options) error
MatchFunc uses the provided match function to determine when the playback should be terminated based on DTMF input.
func MatchHash ¶
MatchHash indicates that the playback should be considered Matched and terminated if it contains a hash (#). The hash (and any subsequent digits) is removed from the final result.
func MatchLen ¶
MatchLen indicates that the playback should be considered Matched and terminated if the given number of DTMF digits are receieved.
func MatchLenOrTerminator ¶
MatchLenOrTerminator indicates that the playback should be considered Matched and terminated if the given number of DTMF digits are receieved or if the given terminator is received. If the terminator is present, it and any subsequent digits will be removed from the final result.
func MatchTerminator ¶
MatchTerminator indicates that the playback shoiuld be considered Matched and terminated if it contains the provided Terminator string. The terminator (and any subsequent digits) is removed from the final result.
func PlaybackStartTimeout ¶
PlaybackStartTimeout overrides the default playback start timeout
Types ¶
type MatchResult ¶
type MatchResult int
MatchResult indicates the status of a match for the received DTMF of a playback
const ( // Incomplete indicates that there are not enough digits to determine a match Incomplete MatchResult = iota // Complete indicates that a match was found and the current DTMF pattern is complete Complete // Invalid indicates that a match cannot befound from the current DTMF received set Invalid )
type Options ¶
type Options struct {
// contains filtered or unexported fields
}
Options represent the various playback options which can modify the operation of a Playback.
func NewDefaultOptions ¶
func NewDefaultOptions() *Options
NewDefaultOptions returns a set of options which represent reasonable defaults for most simple playbacks.
func NewPromptOptions ¶
func NewPromptOptions() *Options
NewPromptOptions returns a set of options which represent reasonable defaults for most prompt playbacks.
func (*Options) ApplyOptions ¶
ApplyOptions applies a set of options to the Playback
func (*Options) Done ¶
func (o *Options) Done() <-chan struct{}
Done returns a channel which is closed when the playback exits
type Result ¶
type Result struct { // Duration indicates how long the playback execution took, from start to finish Duration time.Duration // DTMF records any DTMF which was received by the playback, as modified by any match functions DTMF string // Error indicates any error encountered which caused the termination of the playback Error error // MatchResult indicates the final result of any applied match function for DTMF digits which were received MatchResult MatchResult // Status indicates the resulting status of the playback, why it was stopped Status Status // contains filtered or unexported fields }
Result describes the result of a playback operation
type Status ¶
type Status int
Status indicates the final status of a playback, be it individual of an entire sequence. This Status indicates the reason the playback stopped.
const ( // InProgress indicates that the audio is currently playing or is staged to play InProgress Status = iota // Cancelled indicates that the audio was cancelled. This cancellation could be due // to anything from the control context being closed or a DTMF Match being found Cancelled // Failed indicates that the audio playback failed. This indicates that one // or more of the audio playbacks failed to be played. This could be due to // a system, network, or Asterisk error, but it could also be due to an // invalid audio URI. Check the returned error for more details. Failed // Finished indicates that the playback completed playing all bound audio // URIs in full. Note that for a prompt-style execution, this also means // that no DTMF was matched to the match function. Finished // Hangup indicates that the audio playback was interrupted due to a hangup. Hangup // Timeout indicates that audio playback timed out. It is not known whether this was due to a failure in the playback, a network loss, or some other problem. Timeout )