Package com.bytedesk.call.mrcp4j.client
Class MrcpChannel
java.lang.Object
com.bytedesk.call.mrcp4j.client.MrcpChannel
- All Implemented Interfaces:
MrcpMessageHandler
Provides all primary functionality required for an MRCPv2 client to interact with an MRCPv2 resource. Through an instance of this class
clients can construct and send MRCP requests, receive responses and be notified of events triggered by the MRCP resource.
To construct a MrcpChannel instance use MrcpProvider.createChannel(java.lang.String, java.net.InetAddress, int, java.lang.String).
- Author:
- Niels Godfredsen <ngodfredsen@users.sourceforge.net>
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate ChannelIdentifierprivate List<MrcpEventListener>private longprivate MrcpResponseprivate Objectprivate MrcpSocket -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddEventListener(MrcpEventListener listener) Registers an event listener that will be notified of any MRCP events received on this channel.createRequest(MrcpMethodName methodName) Creates a request object associated with this channel.createVendorSpecificRequest(String methodName) Retrieves the channel ID associated with this channel.voidhandleMessage(MrcpMessage message) Called when an MRCP message is received from an MRCP resource.voidremoveEventListener(MrcpEventListener listener) Unregisters an event listener that may have been registered to receive MRCP events from this channel.sendRequest(MrcpRequest request) Invokes a request on the MRCP resource associated with this channel.
-
Field Details
-
_response
-
_responseLock
-
_listeners
-
_channelID
-
_socket
-
_requestID
private long _requestID
-
-
Constructor Details
-
MrcpChannel
MrcpChannel(String channelID, MrcpSocket socket) throws IllegalValueException - Throws:
IllegalValueException
-
-
Method Details
-
getChannelID
Retrieves the channel ID associated with this channel.- Returns:
- the channel ID associated with this channel.
-
createRequest
Creates a request object associated with this channel. The request object can then be passed tosendRequest(com.bytedesk.call.mrcp4j.message.request.MrcpRequest)(after setting content or other parameters) in order to actually invoke the request on the MRCP resource accessed by this channel.- Parameters:
methodName- name of the method the desired request object should represent.- Returns:
- request object representing the specified method call.
-
createVendorSpecificRequest
-
sendRequest
public MrcpResponse sendRequest(MrcpRequest request) throws IOException, MrcpInvocationException, InterruptedException Invokes a request on the MRCP resource associated with this channel.- Parameters:
request- specification of the request to be invoked.- Returns:
- the response provided by the MRCP resource to the specified request.
- Throws:
IOException- if an I/O error occurs.MrcpInvocationException- if the MRCP resource returned a response error codeInterruptedException- if another thread interrupted the current thread while the current thread was waiting for a response from the MRCP resource.
-
addEventListener
Registers an event listener that will be notified of any MRCP events received on this channel.- Parameters:
listener- instance to be notified of MRCP events received on this channel.
-
removeEventListener
Unregisters an event listener that may have been registered to receive MRCP events from this channel.- Parameters:
listener- instance to be removed from listeners to events received on this channel.
-
handleMessage
Description copied from interface:MrcpMessageHandlerCalled when an MRCP message is received from an MRCP resource.- Specified by:
handleMessagein interfaceMrcpMessageHandler- Parameters:
message- the message received from the MRCP resource
-