public interface Session
A Session can be obtained via the
JVoiceXml.createSession(ConnectionInformation) method.
A client usually performs the following method calls to interact with the interpreter:
Note, that a call to call(URI) must be followed by
a call to hangup() in order to free resources such as ASR and TTS.
The call method returns immediately. In case of an error the client
does not get notified. In order to monitor the call and retrieve error
messages, clients should use the waitSessionEnd
method. This may be done synchronously right after the
call method call or asynchronously in a thread.
| Modifier and Type | Method and Description |
|---|---|
void |
addSessionListener(SessionListener listener)
Adds the session listener.
|
Application |
call(java.net.URI uri)
Handles a call request.
|
Application |
getApplication()
Retrieves the application that is currently being processed.
|
DtmfInput |
getDtmfInput()
Retrieves the DTMF input device.
|
ErrorEvent |
getLastError()
Retrieves an error, if any, that happened during call processing.
|
java.lang.String |
getSessionId()
Retrieves the universal unique identifier for this session.
|
void |
hangup()
Closes this session.
|
boolean |
hasEnded()
Checks if this session has ended.
|
void |
removeSessionListener(SessionListener listener)
Removes the session listener.
|
void |
waitSessionEnd()
Delays until the session ends.
|
void addSessionListener(SessionListener listener)
listener - the session listener to add.void removeSessionListener(SessionListener listener)
listener - the session listener to remove.java.lang.String getSessionId()
Application call(java.net.URI uri) throws ErrorEvent
Starts processing of the given application and returns immediately.
Since this method returns immediately, it offers no means to monitor the
call processing and catch exceptions. Therefore clients are requested
to use the waitSessionEnd() method to monitor the session.
Another way can be via the Telephony
interface and calling getLastError(). However, the latter
option relies on the concrete implementation.
Ensure that you call hangup() after this call
to ensure that resources like ASR and TTS are released.
uri - URI of the first document to load.ErrorEvent - Error initiating the call.void hangup()
Application getApplication()
DtmfInput getDtmfInput() throws NoresourceError, ConnectionDisconnectHangupEvent
NoresourceError - Input device is not available.ConnectionDisconnectHangupEvent - the user hung upboolean hasEnded()
true if the session has ended.void waitSessionEnd()
throws ErrorEvent
ErrorEvent - Error waiting for the end of the call.ErrorEvent getLastError() throws ErrorEvent
null
if there was no error.ErrorEvent - Error reading the last error.