agi

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 17, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

README

AGI

See also

Documentation

Index

Examples

Constants

View Source
const (
	// StatusOK indicates operation was completed successfully.
	StatusOK = 200

	// StatusInvalid indicates invalid or unknown command.
	StatusInvalid = 510

	// StatusDeadChannel indicates the command cant be executed on a dead (closed, terminated, hung up) channel.
	StatusDeadChannel = 511

	// StatusEndUsage indicates end of proper usage, when the command returns its syntax.
	StatusEndUsage = 520
)

Variables

This section is empty.

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.

func Run

func Run(handler HandlerFunc)
Example
package main

import (
	"github.com/ezdev128/astgo/agi"
)

func main() {
	agi.Run(func(session *agi.Session) {
		client := session.Client()
		client.Answer()
		client.StreamFile("activated", "#")
		client.SetVariable("AGISTATUS", "SUCCESS")
		client.Hangup()
	})
}

Types

type ConfEnv

type ConfEnv struct {
	ConfigDir  string
	ConfigFile string
	ModuleDir  string
	SpoolDir   string
	MonitorDir string
	VarDir     string
	DataDir    string
	LogDir     string
	AGIDir     string
	KeyDir     string
	RunDir     string
}

func LoadConfEnv

func LoadConfEnv() ConfEnv

type HandlerFunc

type HandlerFunc func(session *Session)

type Request

type Request struct {
}

type RequestVariable

type RequestVariable struct {
	Request      string
	Channel      string
	Language     string
	Type         string
	UniqueID     string
	Version      string
	CallerID     string
	CallerIDName string
	CallingPres  int // presentation of callerid
	CallingAni2  int
	CallingTon   int    // ast_channel_caller(chan)->id.number.plan
	CallingTns   int    // ast_channel_dialed(chan)->transit_network_select)
	DNID         string // ast_channel_dialed(chan)->number.str
	RDNIS        string // ast_channel_redirecting(chan)->from.number.valid, ast_channel_redirecting(chan)->from.number.str
	Context      string
	Extension    string
	Priority     int
	Enhanced     bool
	AccountCode  string
	ThreadID     int
	Args         []string
}

func (*RequestVariable) Load

func (rc *RequestVariable) Load(m map[string]string)

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
}

func ParseResponse

func ParseResponse(s string) *Response

func (*Response) Err

func (r *Response) Err() error

Err returns the error value from the response

func (*Response) Res

func (r *Response) Res() (string, error)

Res returns the ResultString of a Response, as well as any error encountered. Depending on the command, this is sometimes more useful than Val()

func (*Response) Val

func (r *Response) Val() (string, error)

Val returns the response value and error

type Session

type Session struct {
	Variables map[string]string
	// contains filtered or unexported fields
}

func NewSession

func NewSession(c context.Context, r io.Reader, w io.Writer, conn net.Conn) (*Session, error)

func (*Session) Client

func (a *Session) Client() *agimodels.Client

func (*Session) Close

func (a *Session) Close() (err error)

Close closes any network connection associated with the AGI instance

func (*Session) Command

func (a *Session) Command(cmd string) *Response

func (*Session) RequestVariable

func (a *Session) RequestVariable() *RequestVariable

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL