- data Digit
- ppDigit :: Digit -> Char
- ppEscapeDigits :: [Digit] -> String
- digitsToInteger :: [Digit] -> Maybe Integer
- type AGI = AGIT IO
- run :: MonadIO m => AGIT m a -> Handler -> m a
- fastAGI :: Maybe PortID -> (HostName -> PortNumber -> AGI a) -> IO ()
- runInternal :: MonadIO m => AGIT m a -> Handle -> Handle -> m a
- data SoundType
- sendRecv :: MonadIO m => Command -> AGIT m String
- answer :: MonadIO m => AGIT m Bool
- hangUp :: MonadIO m => Maybe String -> AGIT m Bool
- getData :: MonadIO m => FilePath -> Maybe Integer -> Maybe Integer -> AGIT m (Maybe ([Digit], Bool))
- data RecordResult
- = FailureToWrite
- | FailureOnWaitFor
- | HangUp
- | Interrupted Digit
- | Timeout
- | RandomError String
- sayDigits :: MonadIO m => [Digit] -> [Digit] -> AGIT m (Maybe (Maybe Digit))
- sayNumber :: MonadIO m => Integer -> [Digit] -> AGIT m (Maybe (Maybe Digit))
- streamFile :: MonadIO m => FilePath -> [Digit] -> Maybe Integer -> AGIT m (Either Integer (Maybe Digit, Integer))
- waitForDigit :: MonadIO m => Integer -> AGIT m (Maybe (Maybe Digit))
- record :: MonadIO m => FilePath -> SoundType -> [Digit] -> Maybe Integer -> Maybe Integer -> Bool -> Maybe Integer -> AGIT m (RecordResult, Integer)
Documentation
DTMF digits
ppEscapeDigits :: [Digit] -> StringSource
convert a list of Digit
s into a quoted string.
The quoted string format is used by many AGI commands
digitsToInteger :: [Digit] -> Maybe IntegerSource
run :: MonadIO m => AGIT m a -> Handler -> m aSource
Top-level wrapper for single-shot AGI scripts.
Example:
main = run yourAGI Ignore
fastAGI :: Maybe PortID -> (HostName -> PortNumber -> AGI a) -> IO ()Source
Top-level for long running AGI scripts.
Example:
main = fastAGI Nothing yourAGI
You should be sure to compile with -threaded. Note that yourAGI
may be running simultaneously in multiple threads, so you will need
some concurrency control for shared data.
TODO: support a hang-up handler TODO: ability to listen on a specific IP address
runInternal :: MonadIO m => AGIT m a -> Handle -> Handle -> m aSource
runInternal - run an AGI script using the supplied Handles for input and output
You probably want run
or fastAGI
. This function is exposed so
that 3rd party libraries such as HAppS can easily add support for
FastAGI support.
TODO: support general method of handling extra arguments (query_string vs command-line arguments)
sendRecv :: MonadIO m => Command -> AGIT m StringSource
send an AGI Command, and return the Response
this function provides the low-level send/receive functionality.
answer
channel if not already in answer state
hangUp the specified channel
:: MonadIO m | |
=> FilePath | file to stream |
-> Maybe Integer | timout in ms after keypress (default: 2000 ms) |
-> Maybe Integer | max |
-> AGIT m (Maybe ([Digit], Bool)) | Nothing on failure, Just (digits, timeout) on success |
play a file and return and digits pressed
See also: streamFile
data RecordResult Source
:: MonadIO m | |
=> [Digit] | digits to say |
-> [Digit] | digits which can stop playback |
-> AGIT m (Maybe (Maybe Digit)) | Nothing on error, Just Nothing on success. Just (Just digit) if interrupted. |
say the given digit string
:: MonadIO m | |
=> Integer | number to say |
-> [Digit] | return early if any of these digits are received |
-> AGIT m (Maybe (Maybe Digit)) | Nothing on failure, Just Nothing on success, Just (Just digit) if key is pressed |
sayNumber
says the specified number
:: MonadIO m | |
=> FilePath | file to stream |
-> [Digit] | escape digits |
-> Maybe Integer | sample offset |
-> AGIT m (Either Integer (Maybe Digit, Integer)) | On failure: Left endpos. On success: Right (Maybe Digit, endpos) |
playback the specified file, can be interupted by the given digits.
See also: getData
:: MonadIO m | |
=> Integer | timeout in milliseconds, -1 to block indefinitely |
-> AGIT m (Maybe (Maybe Digit)) | |Nothing| on error, |Just Nothing| on timeout, |Just (Just digit)| on success |
wait for channel to receive a DTMF digit.
See also: getData
for multiple digits
:: MonadIO m | |
=> FilePath | record to this file |
-> SoundType | |GSM | WAV| |
-> [Digit] | stop recording if one of these digits is entered |
-> Maybe Integer | maximum record time in milliseconds, -1 for no timeout |
-> Maybe Integer | offset samples |
-> Bool | beep to indicate recording has begun |
-> Maybe Integer | stop recording if this many seconds of silence passes |
-> AGIT m (RecordResult, Integer) | exit condition, endpos=offset |
record channel to a file