Documentation
¶
Index ¶
- Constants
- Variables
- func Listen(addr string, handler HandlerFunc) error
- type AGI
- func (a *AGI) Answer() error
- func (a *AGI) Close() (err error)
- func (a *AGI) Command(timeout time.Duration, cmd ...string) (resp *Response)
- func (a *AGI) EAGI() io.Reader
- func (a *AGI) Exec(timeout time.Duration, cmd ...string) (string, error)
- func (a *AGI) Get(key string) (string, error)
- func (a *AGI) GetData(sound string, timeout time.Duration, maxdigits int) (digits string, err error)
- func (a *AGI) Hangup() error
- func (a *AGI) Record(name string, opts *RecordOptions) error
- func (a *AGI) SayAlpha(label string, escapeDigits string) (digit string, err error)
- func (a *AGI) SayDate(when time.Time, escapeDigits string) (digit string, err error)
- func (a *AGI) SayDateTime(when time.Time, escapeDigits string, format string) (digit string, err error)
- func (a *AGI) SayDigits(number string, escapeDigits string) (digit string, err error)
- func (a *AGI) SayNumber(number string, escapeDigits string) (digit string, err error)
- func (a *AGI) SayPhonetic(phrase string, escapeDigits string) (digit string, err error)
- func (a *AGI) SayTime(when time.Time, escapeDigits string) (digit string, err error)
- func (a *AGI) Set(key, val string) error
- func (a *AGI) SetLogger(l *log.Logger) error
- func (a *AGI) Status() (State, error)
- func (a *AGI) StreamFile(name string, escapeDigits string, offset int) (digit string, err error)
- func (a *AGI) Verbose(msg string, level int) error
- func (a *AGI) Verbosef(format string, args ...interface{}) error
- func (a *AGI) WaitForDigit(timeout time.Duration) (digit string, err error)
- type HandlerFunc
- type RecordOptions
- type Response
- type State
Constants ¶
const ( // StatusOK indicates the AGI command was // accepted. StatusOK = 200 // StatusInvalid indicates Asterisk did not // understand the command. StatusInvalid = 510 // StatusDeadChannel indicates that the command // cannot be performed on a dead (hungup) channel. StatusDeadChannel = 511 // StatusEndUsage indicates...TODO StatusEndUsage = 520 )
Variables ¶
var ErrHangup = errors.New("hangup")
ErrHangup indicates the channel hung up during processing
Functions ¶
func Listen ¶
func Listen(addr string, handler HandlerFunc) error
Listen binds an AGI HandlerFunc to the given TCP `host:port` address, creating a FastAGI service.
Types ¶
type AGI ¶
type AGI struct { // Variables stored the initial variables // transmitted from Asterisk at the start // of the AGI session. Variables map[string]string // contains filtered or unexported fields }
AGI represents an AGI session
func NewEAGI ¶
func NewEAGI() *AGI
NewEAGI returns a new AGI session to stdin, the EAGI stream (FD=3), and stdout.
func NewWithEAGI ¶
NewWithEAGI returns a new AGI session to the given `os.Stdin` `io.Reader`, EAGI `io.Reader`, and `os.Stdout` `io.Writer`. The initial variables will be read in.
func (*AGI) Command ¶
Command sends the given command line to stdout and returns the response. TODO: this does not handle multi-line responses properly
func (*AGI) GetData ¶
func (a *AGI) GetData(sound string, timeout time.Duration, maxdigits int) (digits string, err error)
GetData plays a file and receives DTMF, returning the received digits
func (*AGI) Record ¶
func (a *AGI) Record(name string, opts *RecordOptions) error
Record records audio to a file
func (*AGI) SayDateTime ¶
func (a *AGI) SayDateTime(when time.Time, escapeDigits string, format string) (digit string, err error)
SayDateTime plays a date using the given format. See `voicemail.conf` for the format syntax; defaults to `ABdY 'digits/at' IMp`.
func (*AGI) SayPhonetic ¶
SayPhonetic plays the given phrase phonetically
func (*AGI) StreamFile ¶
StreamFile plays the given file to the channel
type HandlerFunc ¶
type HandlerFunc func(*AGI)
HandlerFunc is a function which accepts an AGI instance
type RecordOptions ¶
type RecordOptions struct { // Format is the format of the audio file to record; defaults to "wav". Format string // EscapeDigits is the set of digits on receipt of which will terminate the recording. Default is "#". This may not be blank. EscapeDigits string // Timeout is the maximum time to allow for the recording. Defaults to 5 minutes. Timeout time.Duration // Silence is the maximum amount of silence to allow before ending the recording. The finest resolution is to the second. 0=disabled, which is the default. Silence time.Duration // Beep controls whether a beep is played before starting the recording. Defaults to false. Beep bool // Offset is the number of samples in the recording to advance before storing to the file. This is means of clipping the beginning of a recording. Defaults to 0. Offset int }
RecordOptions describes the options available when recording
type Response ¶
type Response struct { Error error // Error received, if any Status int // HTTP-style status code received Result int // Result is the numerical return (if parseable) ResultString string // Result value as a string Value string // Value is the (optional) string value returned }
Response represents a response to an AGI request.
type State ¶
type State int
State describes the Asterisk channel state. There are mapped directly to the Asterisk enumerations.
const ( // StateDown indicates the channel is down and available StateDown State = iota // StateReserved indicates the channel is down but reserved StateReserved // StateOffhook indicates that the channel is offhook StateOffhook // StateDialing indicates that digits have been dialed StateDialing // StateRing indicates the channel is ringing StateRing // StateRinging indicates the channel's remote end is rining (the channel is receiving ringback) StateRinging // StateUp indicates the channel is up StateUp // StateBusy indicates the line is busy StateBusy // StateDialingOffHook indicates digits have been dialed while offhook StateDialingOffHook // StatePreRing indicates the channel has detected an incoming call and is waiting for ring StatePreRing )