Class AsteriskAGIHandler
- All Implemented Interfaces:
Runnable
,Handler
,TemplateInterface
(Implementation notes)
This class implements 4 different threads:
- handler/init: to get the config params and start the listening socket
- The thread that listens and accepts connections from *
- the threads that handle the incoming agi requests
- the threads that do the template <agi...> stuff
-
Field Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
done
(RewriteContext hr) Close the socket connection.boolean
Start a Listening socket thread, and wait for AGI connections.boolean
init
(RewriteContext hr) Open the socket's streams at top of page.boolean
We don't handle any "normal" requests.void
run()
Either start a listening socket or handle an AGI request.void
Provide the 'agi' tag.
-
Constructor Details
-
AsteriskAGIHandler
public AsteriskAGIHandler()
-
-
Method Details
-
init
Start a Listening socket thread, and wait for AGI connections.- Specified by:
init
in interfaceHandler
- Parameters:
server
- The HTTP server that created thisHandler
. TypicalHandler
s will useServer.props
to obtain run-time configuration information.prefix
- The handlers name. The string thisHandler
may prepend to all of the keys that it uses to extract configuration information fromServer.props
. This is set (by theServer
andChainHandler
) to help avoid configuration parameter namespace collisions.- Returns:
true
if thisHandler
initialized successfully,false
otherwise. Iffalse
is returned, thisHandler
should not be used.
-
respond
We don't handle any "normal" requests.- Specified by:
respond
in interfaceHandler
- Parameters:
request
- TheRequest
object that represents the HTTP request.- Returns:
- always false
- Throws:
IOException
- if there was an I/O error while sending the response to the client. Typically, in that case, theServer
will (try to) send an error message to the client and then close the client's connection.The
IOException
should not be used to silently ignore problems such as being unable to access some server-side resource (for example getting aFileNotFoundException
due to not being able to open a file). In that case, theHandler
's duty is to turn thatIOException
into a HTTP response indicating, in this case, that a file could not be found.
-
init
Open the socket's streams at top of page. This will be used by the <agi> calls.- Specified by:
init
in interfaceTemplateInterface
- Overrides:
init
in classTemplate
-
done
Close the socket connection.- Specified by:
done
in interfaceTemplateInterface
- Overrides:
done
in classTemplate
-
tag_agi
Provide the 'agi' tag. <agi command="agi command"> The result is placed in "agi_result". NOTE: the thread running this instance doesn't set any of the instance variables. We get everything from "hr". -
run
public void run()Either start a listening socket or handle an AGI request.
-