Documentation ¶
Index ¶
- Variables
- type AGI
- func (agi *AGI) Answer() (Response, error)
- func (agi *AGI) AsyncAGIBreak() (Response, error)
- func (agi *AGI) ChannelStatus(channel string) (Response, error)
- func (agi *AGI) Close()
- func (agi *AGI) Command(cmd string) (Response, error)
- func (agi *AGI) ControlStreamFile(filename, digits string, args ...string) (Response, error)
- func (agi *AGI) DatabaseDel(family, key string) (Response, error)
- func (agi *AGI) DatabaseDelTree(family, keytree string) (Response, error)
- func (agi *AGI) DatabaseGet(family, key string) (Response, error)
- func (agi *AGI) DatabasePut(family, key, val string) (Response, error)
- func (agi *AGI) Env(key string) string
- func (agi *AGI) EnvArgs() []string
- func (agi *AGI) Exec(app, opts string) (Response, error)
- func (agi *AGI) GetData(file string, timeout, maxdigit int) (Response, error)
- func (agi *AGI) GetFullVariable(name, channel string) (Response, error)
- func (agi *AGI) GetOption(filename, digits string, timeout int32) (Response, error)
- func (agi *AGI) GetVariable(name string) (Response, error)
- func (agi *AGI) Hangup(channel ...string) (Response, error)
- func (agi *AGI) IsHungup() bool
- func (agi *AGI) ReceiveChar(timeout int) (Response, error)
- func (agi *AGI) ReceiveText(timeout int) (Response, error)
- func (agi *AGI) RecordFile(file, format, escDigits string, timeout, offset int, beep bool, silence int) (Response, error)
- func (agi *AGI) SayAlpha(line, escDigits string) (Response, error)
- func (agi *AGI) SayDate(date, escDigits string) (Response, error)
- func (agi *AGI) SayDatetime(time, escDigits, format, timezone string) (Response, error)
- func (agi *AGI) SayDigits(number, escDigits string) (Response, error)
- func (agi *AGI) SayNumber(number, escDigits string) (Response, error)
- func (agi *AGI) SayPhonetic(str, escDigits string) (Response, error)
- func (agi *AGI) SayTime(time, escDigits string) (Response, error)
- func (agi *AGI) SendImage(image string) (Response, error)
- func (agi *AGI) SendText(text string) (Response, error)
- func (agi *AGI) SetAutoHangup(seconds int) (Response, error)
- func (agi *AGI) SetCallerid(clid string) (Response, error)
- func (agi *AGI) SetContext(ctx string) (Response, error)
- func (agi *AGI) SetExtension(ext string) (Response, error)
- func (agi *AGI) SetMusic(enable bool, class string) (Response, error)
- func (agi *AGI) SetPriority(priority string) (Response, error)
- func (agi *AGI) SetVariable(name, value string) (Response, error)
- func (agi *AGI) StreamFile(file, escDigits string, offset int) (Response, error)
- func (agi *AGI) TDDMode(mode string) (Response, error)
- func (agi *AGI) Verbose(msg string, level ...int) (Response, error)
- func (agi *AGI) WaitForDigit(timeout int) (Response, error)
- type Debugger
- type Error
- type Reader
- type Response
- type Writer
Constants ¶
This section is empty.
Variables ¶
var ErrAGI = newError("AGI session")
ErrAGI goagi error
Functions ¶
This section is empty.
Types ¶
type AGI ¶
type AGI struct {
// contains filtered or unexported fields
}
AGI object
func New ¶ added in v1.1.0
New creates and returns AGI object. Can be used to create agi and fastagi sessions.
Parameters:
- Reader that implements Read method
- Writer that implements Write method
- Debugger that allows to deep library debugging. Nil for production.
func (*AGI) Answer ¶
Answer executes AGI command "ANSWER" Answers channel if not already in answer state.
func (*AGI) AsyncAGIBreak ¶
AsyncAGIBreak Interrupts Async AGI
Interrupts expected flow of Async AGI commands and returns control
to previous source (typically, the PBX dialplan).
func (*AGI) ChannelStatus ¶
ChannelStatus returns status of the connected channel.
If no channel name is given (empty line) then returns the status of the current channel.
Return values:
0 - Channel is down and available.
1 - Channel is down, but reserved.
2 - Channel is off hook.
3 - Digits (or equivalent) have been dialed.
4 - Line is ringing.
5 - Remote end is ringing.
6 - Line is up.
7 - Line is busy.
func (*AGI) Command ¶
Command sends command as string to the AGI and returns response valus with text response
func (*AGI) ControlStreamFile ¶
ControlStreamFile sends audio file on channel and allows the listener to control the stream. Send the given file, allowing playback to be controlled by the given digits, if any. Use double quotes for the digits if you wish none to be permitted. If offsetms is provided then the audio will seek to offsetms before play starts.
Example:
agi.ControlStreamFile("prompt_en", "19", "3000", "#", "0", "#", "1600") agi.ControlStreamFile("prompt_en", "") agi.ControlStreamFile("prompt_en", "19", "", "", "", "#", "1600")
func (*AGI) DatabaseDel ¶
DatabaseDel deletes an entry in the Asterisk database for a given family and key.
Returns status and error if fails.
func (*AGI) DatabaseDelTree ¶
DatabaseDelTree deletes a family or specific keytree within a family in the Asterisk database.
func (*AGI) DatabaseGet ¶
DatabaseGet Retrieves an entry in the Asterisk database for a given family and key.
Returns value as string or error if failed or value not set Response.Value() for result
func (*AGI) DatabasePut ¶
DatabasePut adds or updates an entry in the Asterisk database for a given family, key, and value.
func (*AGI) GetData ¶
GetData Stream the given file, and receive DTMF data. Note: when timeout is 0 then Asterisk will use 6 seconds. Note: Asterisk has strange way to handle get data response. Contrary to other responses, where result has numeric value, here asterisk puts DTMF to sent by user to result and this value may contain "#" and "*".
To get DTMF sent by user use Response.Data()
Response.Value() will contain "timeout" if user has not terminated input with "#"
func (*AGI) GetFullVariable ¶
GetFullVariable evaluates a channel expression
func (*AGI) GetOption ¶
GetOption Stream file, prompt for DTMF, with timeout.
Behaves similar to STREAM FILE but used with a timeout option. Returns digit pressed, offset and error
func (*AGI) GetVariable ¶
GetVariable Gets a channel variable.
func (*AGI) Hangup ¶
Hangup hangs up the specified channel. If no channel name is given, hangs up the current channel
func (*AGI) ReceiveChar ¶
ReceiveChar Receives one character from channels supporting it. Most channels do not support the reception of text. Returns the decimal value of the character if one is received, or 0 if the channel does not support text reception.
timeout - The maximum time to wait for input in milliseconds, or 0 for infinite.
Returns result -1 on error or char byte
func (*AGI) ReceiveText ¶
ReceiveText Receives text from channels supporting it.
timeout - The timeout to be the maximum time to wait for input in milliseconds, or 0 for infinite.
func (*AGI) RecordFile ¶
func (agi *AGI) RecordFile(file, format, escDigits string, timeout, offset int, beep bool, silence int) (Response, error)
RecordFile Record to a file until a given dtmf digit in the sequence is received. The format will specify what kind of file will be recorded. The timeout is the maximum record time in milliseconds, or -1 for no timeout.
offset samples is optional, and, if provided, will seek to the offset without exceeding the end of the file.
beep causes Asterisk to play a beep to the channel that is about to be recorded.
silence is the number of seconds of silence allowed before the function returns despite the lack of dtmf digits or reaching timeout.
silence is the number of seconds of silence that are permitted before the recording is terminated, regardless of the escape_digits or timeout arguments
If interrupted by DTMF, digits will be available in Response.Data()
func (*AGI) SayAlpha ¶
SayAlpha says a given character string, returning early if any of the given DTMF digits are received on the channel.
func (*AGI) SayDate ¶
SayDate say a given date, returning early if any of the given DTMF digits are received on the channel
func (*AGI) SayDatetime ¶
SayDatetime say a given time, returning early if any of the given DTMF digits are received on the channel
func (*AGI) SayDigits ¶
SayDigits say a given digit string, returning early if any of the given DTMF digits are received on the channel
func (*AGI) SayNumber ¶
SayNumber say a given digit string, returning early if any of the given DTMF digits are received on the channel
func (*AGI) SayPhonetic ¶
SayPhonetic say a given character string with phonetics, returning early if any of the given DTMF digits are received on the channel
func (*AGI) SayTime ¶
SayTime say a given time, returning early if any of the given DTMF digits are received on the channel
func (*AGI) SendImage ¶
SendImage Sends the given image on a channel. Most channels do not support the transmission of images.
func (*AGI) SendText ¶
SendText Sends the given text on a channel. Most channels do not support the transmission of text.
func (*AGI) SetAutoHangup ¶
SetAutoHangup Cause the channel to automatically hangup at time seconds in the future. Setting to 0 will cause the autohangup feature to be disabled on this channel.
func (*AGI) SetCallerid ¶
SetCallerid Changes the callerid of the current channel.
func (*AGI) SetContext ¶
SetContext Sets the context for continuation upon exiting the application.
func (*AGI) SetExtension ¶
SetExtension Changes the extension for continuation upon exiting the application.
func (*AGI) SetMusic ¶
SetMusic Enables/Disables the music on hold generator. If class is not specified, then the default music on hold class will be used.
func (*AGI) SetPriority ¶
SetPriority Changes the priority for continuation upon exiting the application. The priority must be a valid priority or label.
func (*AGI) SetVariable ¶
SetVariable Sets a variable to the current channel.
func (*AGI) StreamFile ¶
StreamFile Send the given file, allowing playback to be interrupted by the given digits, if any.
func (*AGI) TDDMode ¶
TDDMode Enable/Disable TDD transmission/reception on a channel. Modes: on, off, mate, tdd
type Debugger ¶ added in v1.1.0
type Debugger interface {
Printf(format string, v ...interface{})
}
Debugger for AGI instance. Any interface that provides Printf method. It should be used only for debugging as it give lots of output.
type Error ¶ added in v1.1.0
type Error struct {
// contains filtered or unexported fields
}
Error object for goagi library
type Response ¶ added in v1.1.0
type Response interface { // Code of response: 200, 510 etc Code() int // RawResponse return full text of AGI response RawResponse() string // Result returns value of result= field Result() int // Value returns value field: (timeout) Value() string // Data returns text for error responses and dtmf values for command like GetData Data() string // EndPos returns value for endpos= field EndPos() int64 // Digit return digit from digit= field Digit() string // SResults return value for results= field SResults() int }
Response interface that all commands return. Helps to access different parts of AGI response