AsyncChannel
, AsyncChannelOperations
, AsyncInvokerSupport
, Channel
, ChannelListenerSupport
, ConfigurationSupport
, ConnectionInvokerSupport
, EndpointSupport
, InputChannel
, InterceptorSupport
, LogMessageFilterSupport
, MessageReceiver
, MessageReceiverManagement
, OutputChannel
, Protocol
, ProtocolDescriptionSupport
, Receiver
, ReceiverManagement
, RequestChannel
ConfServerProtocol
, ExternalServiceProtocol
, InteractionServerProtocol
, LcaUdpHeartbeatInternalProtocol
, LocalControlAgentProtocol
, MessageServerProtocol
, OutboundServerProtocol
, RoutingServerProtocol
, SolutionControlServerProtocol
, StatServerProtocol
, TServerProtocol
, UrsCustomProtocol
, WebmediaChannel
public class ClientChannel extends DuplexChannel implements Protocol
ClientChannel
is the parent class of all of the
Protocol
classes used for client applications
in the Platform SDK, such as TServerProtocol
and
ConfServerProtocol
.
Modifier and Type | Class | Description |
---|---|---|
protected class |
ClientChannel.BasicClientHandshakeStep |
Abstract class with common or some default logic for client handshake steps.
|
protected static interface |
ClientChannel.ClientHandshakeStep |
Interface representing client side step of a protocol handshake procedure.
|
protected static interface |
ClientChannel.RegistrationHandler |
Deprecated.
|
protected class |
ClientChannel.SimpleRegistrationHandler |
Deprecated.
|
AbstractChannel.AsyncErrorNotifier
DEFAULT_TIMEOUT, INFINITE_TIMEOUT
messageFilter
DEF_INPUT_SIZE
Constructor | Description |
---|---|
ClientChannel(Endpoint endpoint,
ProtocolFactory protocolFactory,
ReferenceBuilder refBuilder) |
|
ClientChannel(Endpoint endpoint,
ProtocolFactory protocolFactory,
ReferenceBuilder refBuilder,
long timeout) |
Modifier and Type | Method | Description |
---|---|---|
void |
beginClose() |
Closes channel asynchronously.
|
void |
beginOpen() |
Begins channel opening asynchronously.
|
RequestFuture |
beginRequest(Message message) |
Starts request and exits.
|
void |
close(boolean force) |
Closes channel synchronously.
|
void |
close(long timeout) |
Closes channel synchronously.
|
java.util.concurrent.Future<ChannelClosedEvent> |
closeAsync() |
Close the channel asynchronously.
|
<A> void |
closeAsync(long timeout,
CompletionHandler<ChannelClosedEvent,A> handler,
A attachment) |
Open channel asynchronously.
|
ConnectionOperations |
disableConnectionOperations() |
Disable connection operations.
|
protected MessageCorrelator.MessageEntry |
doBeginRequest(Message message) |
Deprecated.
|
protected <A> MessageCorrelator.MessageEntry |
doBeginRequest(Message message,
A attachment,
CompletionHandler<Message,? super A> handler,
long timeout) |
|
protected Message |
doRequest(Message message,
long timeout) |
|
Message |
endRequest(RequestFuture future) |
Tries to finish request started with
beginRequest() . |
Message |
endRequest(RequestFuture future,
long timeout) |
Tries to finish request started with
beginRequest(Message) . |
void |
fireUnsolicitedEvents() |
|
boolean |
getCopyResponse() |
Is response to
request() copied to receive queue. |
AsyncInvoker |
getInvoker() |
Deprecated.
For internal use only!
|
protected ProtocolException |
getOpenTimeoutException(long timeout) |
Creates open timeout exception and logs it.
|
ReferenceBuilder |
getReferenceBuilder() |
|
protected void |
onOpen() |
This method is called when channel is opened and just about
to call event handler.
|
protected void |
onReceiveMessage(Message msg) |
Gives to subclass a chance to perform some operations on incoming
message arrival before delivering it to connection user code.
|
protected void |
onSend(Message message) |
Gives to subclass a chance to modify message before sending it
to remote party.
|
protected void |
onUnexpectedHandshakeMessage(Message request,
Message response,
java.util.Queue<Message> msgsBuffer) |
Event handler for unexpected messages on handshake procedure, which are not accepted
by the RegistrationHandler, but not caused handshake exception.
Registration handler allows custom handling of such kind of messages in specific protocols. Particular protocol may override this method and, taking into account things like: response message type request message type current result messages queue state ... do add response message to the result queue do nothing to skip response message throw ProtocolException to break handshake procedure throw RegistrationException to break handshake procedure and stop WarmStandbyService (if it exists) After successful handshake procedure finish, messages from the result messages queue will be passed to the MessageHandler . |
void |
open(long timeout) |
Opens the channel by opening underlying connection
including protocol specific handshake procedure using
specified protocol timeout value.
Timeout can be set to following values: positive value - time in ms. |
<A> void |
openAsync(long timeout,
CompletionHandler<java.util.EventObject,A> handler,
A attachment) |
Open channel asynchronously.
|
java.util.concurrent.Future<ChannelOpenedEvent> |
openAsync(java.lang.Long timeout) |
Method is asynchronous.
|
Message |
request(Message message) |
This synchronous method sends the specified request to the server, and
waits for a response from the server for the length of the
timeout property. |
Message |
request(Message message,
long timeout) |
This synchronous method sends the specified request to the server
and waits for a response from the server for the length of the specified
timeout value. |
<A> void |
requestAsync(Message message,
A attachment,
CompletionHandler<Message,? super A> handler) |
Starts request and exits.
|
<A> void |
requestAsync(Message request,
A attachment,
CompletionHandler<Message,? super A> handler,
long timeout) |
Starts request and exits.
|
void |
setAddressResolver(SocketAddressResolver resolver) |
Sets custom SocketAddress resolver reference.
|
void |
setAddressResolverParams(java.lang.String parameters) |
Sets parameters for SocketAddress resolver.
|
void |
setAddressResolverParams(java.util.Map<java.lang.String,java.lang.Object> parameters) |
Sets parameters for SocketAddress resolver.
|
void |
setCopyResponse(boolean copyResponse) |
Is response to
request() copied to receive queue. |
void |
setEndpoint(Endpoint endpoint) |
Sets channel endpoint.
|
protected void |
setHandshakeFinished(java.lang.Throwable exception) |
|
protected void |
setHandshakePhase(ClientChannel.ClientHandshakeStep handshakeStart) |
Initializes.
|
void |
setHandshakeUnsolicitedEventsPassLimit(int maxNum) |
Deprecated.
|
protected void |
setRegistrationHandler(ClientChannel.RegistrationHandler handler) |
Deprecated.
|
protected void |
setState(ChannelState newState,
ConnectionClosedEvent closedEvent) |
|
protected Message |
submitRegMessage(Message regMessage) |
Deprecated.
|
protected void |
throwOnUnReferenceableRequest(Message request) |
addChannelListener, configure, connectionContext, copyTLSSettings, fireClosed, fireErrorEvent, fireErrorEvent, generateChannelId, getChannelId, getConfiguration, getDefaultInvoker, getEndpoint, getListenerHelper, getServerContext, getState, getStateMods, getTimeout, getTimer, internal, onSetEndpoint, releaseDefaultInvoker, removeChannelListener, setConfiguration, setInvoker, setServerContext, setState, setTimeout, throwNotClosed, throwNotOpened, throwNotOpenedOnClose, throwNotOpenedOnSend, throwNull, throwNullEndpoint
getState
setInvoker
close, getTimeout, open, setTimeout
addChannelListener, removeChannelListener
configure, getConfiguration
setConnectionInvoker
addListener, applyConfiguration, cancelCloseTimeout, cancelOpenTimeout, clearInput, close, closeAsync, createChannelClosedEvent, createConnection, createConnectionClosedEvent, doBeginClose, doClose, doSend, downgradeConnection, getConnectionClosedCause, getDefaultRestriction, getEnpointPrefixInfo, getInputSize, getInterceptor, getLocalEndPoint, getLocalEndpointInfo, getLogMessageFilter, getProtocolDescription, getProtocolFactory, getProtocolId, getRemoteEndPoint, getTimeoutException, initPackager, isMessageAllowed, notifyWithObject, onClose, onFireClosed, onFireErrorEvent, onFireOpened, open, openAsync, openAsync, processClose, processCloseAll, receive, receive, receivedMessage, releaseReceivers, removeListener, resetReceiver, resumeReading, send, setConnectionInvoker, setExternalTransport, setInputSize, setLogMessageFilter, setMessageHandler, setProtocolData, setReceiver, startUpgradeConnection, stopReading, toString, triggerWithObject, upgradeConnection, waitForObject, wrapInProtocolException
getEndpoint
setMessageHandler
getInterceptor
receive, receive
setReceiver
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
addListener, removeListener, send
getProtocolId
getProtocolDescription
clearInput, getInputSize, releaseReceivers, setInputSize
resetReceiver
public ClientChannel(Endpoint endpoint, ProtocolFactory protocolFactory, ReferenceBuilder refBuilder, long timeout)
public ClientChannel(Endpoint endpoint, ProtocolFactory protocolFactory, ReferenceBuilder refBuilder)
public Message request(Message message) throws ProtocolException, java.lang.IllegalStateException
timeout
property.
Here is a sample of how to use the request()
method.
Message response =
interactionServerProtocol.request(requestAgentLogin);
The time to wait for a response is configured during channel creation or by
using the setTimeout()
method. This request()
method only waits for messages with a reference ID, so if the message doesn't support
referencing then a null value is returned immediately.
Because this method will not return events for a request that does not include
the ReferenceId
attribute, it is better to use the send()
method for those requests.request
in interface RequestChannel
message
- the request to be sent to the server.null
in the following cases:java.lang.IllegalArgumentException
- if request message is null, message belongs to other protocolChannelClosedOnSendException
- If channel is not in the Opened state.ProtocolException
- in the case of an unrecoverable protocol error. Client applications should not
try to deal with these exceptions, except for logging or displaying to users or technical administrators.
Check the exception cause for more details.ChannelClosedOnRequestException
- If channel has been closed before an answer is received. You can check Throwable.getCause()
to find out the reason why channel has been closed.java.lang.IllegalStateException
- if channel is not in an appropriate state
(e.g. closed)request(Message, long)
public Message request(Message message, long timeout) throws ProtocolException
timeout
value. See request(Message)
.request
in interface RequestChannel
message
- the request to be sent to the server.timeout
- time to waitResponse for response.null
in the following cases:java.lang.IllegalArgumentException
- if request message is null, message belongs to other protocol.ChannelClosedOnSendException
- if channel is not in the Opened state.ChannelClosedOnRequestException
- If channel has been closed before an answer is received. You can check Throwable.getCause()
to find out the reason why channel has been closed.ProtocolException
- in the case of an unrecoverable protocol error. Client applications should not
try to deal with these exceptions, except for logging or displaying to users or technical administrators.
Check the exception cause for more details.public RequestFuture beginRequest(Message message) throws ProtocolException
endRequest(RequestFuture)
method.beginRequest
in interface RequestChannel
message
- message to request with.java.lang.IllegalArgumentException
- if request message is null, message belongs to other protocolRequestUnReferenceableException
- if argument message is not instance of Referenceable
.ChannelClosedOnSendException
- if channel is not in the Opened state.ProtocolException
- in the case of an unrecoverable protocol error. Client applications should not
try to deal with these exceptions, except for logging or displaying to users or technical administrators.
Check the exception cause for more details.AbstractChannel.setTimeout(long)
,
requestAsync(Message, Object, CompletionHandler)
,
endRequest(RequestFuture)
public <A> void requestAsync(Message message, A attachment, CompletionHandler<Message,? super A> handler) throws ProtocolException
requestAsync
in interface RequestChannel
A
- user callback attachment parameter type.message
- message to request with.attachment
- user defined parameter for the "callback".handler
- user defined "callback" interface for notification
about server response.java.lang.IllegalArgumentException
- if result message is null.RequestUnReferenceableException
- if argument message is not instance of Referenceable
.java.lang.IllegalArgumentException
- if callback is not null, but protocol has no positive timeout set.ChannelClosedOnSendException
- if channel is not in the Opened state.ProtocolException
- in the case of an unrecoverable protocol error. Client applications should not
try to deal with these exceptions, except for logging or displaying to users or technical administrators.
Check the exception cause for more details.AbstractChannel.setTimeout(long)
,
requestAsync(Message, Object, CompletionHandler, long)
public <A> void requestAsync(Message request, A attachment, CompletionHandler<Message,? super A> handler, long timeout) throws ProtocolException, java.lang.IllegalStateException
requestAsync
in interface RequestChannel
A
- user callback attachment parameter type.request
- message to request with.attachment
- user defined parameter for the "callback".handler
- user defined "callback" interface for notification
about server response.timeout
- timeout waiting for server response before request invalidation.java.lang.IllegalArgumentException
- if request message is nullRequestUnReferenceableException
- if argument message is not instance of Referenceable
java.lang.IllegalArgumentException
- if callback is not null, but provided timeout is not positive value, message belongs to other protocolChannelClosedOnSendException
- if channel is not in the Opened state.ProtocolException
- in the case of an unrecoverable protocol error. Client applications should not
try to deal with these exceptions, except for logging or displaying to users or technical administrators.
Check the exception cause for more details.java.lang.IllegalStateException
- if channel is in inappropriate state to
execute the requestpublic Message endRequest(RequestFuture future) throws ProtocolException
beginRequest()
.endRequest
in interface RequestChannel
future
- future object obtained from beginRequest()
null
in the following cases:ProtocolException
- in the case of an unrecoverable protocol error. Client applications should not
try to deal with these exceptions, except for logging or displaying to users or technical administrators.
Check the exception cause for more details.ChannelClosedOnRequestException
- If channel has been closed before an answer is received. You can check Throwable.getCause()
to find out the reason why channel has been closed.beginRequest(Message)
public Message endRequest(RequestFuture future, long timeout) throws ProtocolException
beginRequest(Message)
.endRequest
in interface RequestChannel
future
- future object obtained from beginRequest(Message)
.timeout
- timeout to waitResponse for response.null
in the following cases:ProtocolException
- in the case of an unrecoverable protocol error. Client applications should not
try to deal with these exceptions, except for logging or displaying to users or technical administrators.
Check the exception cause for more details.ChannelClosedOnRequestException
- If channel has been closed before an answer is received. You can check Throwable.getCause()
to find out the reason why channel has been closed.request(Message, long)
protected void setState(ChannelState newState, ConnectionClosedEvent closedEvent)
setState
in class DuplexChannel
@Deprecated protected final MessageCorrelator.MessageEntry doBeginRequest(Message message) throws ProtocolException
ProtocolException
doBeginRequest(Message, Object, CompletionHandler, long)
protected final <A> MessageCorrelator.MessageEntry doBeginRequest(Message message, A attachment, CompletionHandler<Message,? super A> handler, long timeout) throws ProtocolException
ProtocolException
protected Message doRequest(Message message, long timeout) throws ProtocolException
ProtocolException
public boolean getCopyResponse()
RequestChannel
request()
copied to receive queue.getCopyResponse
in interface RequestChannel
public void setCopyResponse(boolean copyResponse)
RequestChannel
request()
copied to receive queue.setCopyResponse
in interface RequestChannel
copyResponse
- true if response goes to receive queue@Deprecated public void setHandshakeUnsolicitedEventsPassLimit(int maxNum)
protected void onUnexpectedHandshakeMessage(Message request, Message response, java.util.Queue<Message> msgsBuffer) throws ProtocolException
MessageHandler
.request
- the registration requestresponse
- the unexpected messagemsgsBuffer
- the result messages queueRegistrationException
ProtocolException
- in the case of an unrecoverable protocol error. Client applications should not
try to deal with these exceptions, except for logging or displaying to users or technical administrators.
Check the exception cause for more details.public ReferenceBuilder getReferenceBuilder()
getReferenceBuilder
in interface Protocol
protected void throwOnUnReferenceableRequest(Message request)
public void setEndpoint(Endpoint endpoint)
AbstractChannel
setEndpoint
in interface EndpointSupport
setEndpoint
in class AbstractChannel
endpoint
- endpointDisabledMethodException
- if it the method disableConnectionOperations has been called before.
And channel's open/close operations can't be called directly.public void setAddressResolver(SocketAddressResolver resolver) throws ChannelNotClosedException
resolver
- reference to custom implementation of SocketAddress resolver.ChannelNotClosedException
- if channel is not in Closed
state.setAddressResolverParams(String)
,
setAddressResolverParams(Map)
,
DefaultSocketAddressResolver
public void setAddressResolverParams(java.lang.String parameters) throws ProtocolSecurityException, java.lang.IllegalArgumentException
parameters
- parameters to be passed to the SocketAddress resolver with resolution request.ChannelNotClosedException
- if channel is not in Closed
state.ProtocolSecurityException
- if protocol failed to instantiate custom address resolver by given class name.java.lang.IllegalArgumentException
- in case of parsing exception of the given parameters string.setAddressResolver(SocketAddressResolver)
,
DefaultSocketAddressResolver.setResolver(SocketAddressResolver)
public void setAddressResolverParams(java.util.Map<java.lang.String,java.lang.Object> parameters) throws ChannelNotClosedException, ProtocolSecurityException, java.lang.IllegalArgumentException
parameters
- parameters to be passed to the SocketAddress resolver with resolution request.ChannelNotClosedException
- if channel is not in Closed
state.ProtocolSecurityException
- if protocol failed to instantiate custom address resolver by given class name.java.lang.IllegalArgumentException
- if parameters value is null
or contains invalid value with
the resolver override keys.setAddressResolver(SocketAddressResolver)
,
DefaultSocketAddressResolver.setResolver(SocketAddressResolver)
public void open(long timeout) throws RegistrationException, ProtocolException, ChannelNotClosedException, java.lang.InterruptedException
DuplexChannel
open
in interface Channel
open
in class DuplexChannel
timeout
- time to waitResponse for the connectionProtocolSecurityException
- if any security problems occurs on a channelProtocolIOException
- will thrown if connection IO exception occursProtocolTimeoutException
- if channel wasn't opened for the specified timeChannelEmergencyClosedException
- if channel was closed while openingRegistrationException
- if there is an error related to registration procedure
like server error about wrong client name, user password, etcRegistrationTimeoutException
- if connection to server was established but handshake procedure has timed outProtocolException
- In the case of an unrecoverable protocol error. Client applications should not
try to deal with these exceptions, except for logging or displaying to users or technical administrators.
Check the exception cause for more details.java.lang.IllegalArgumentException
- when channel endpoint is not assignedChannelNotClosedException
- if channel is not in Closed
stateDisabledMethodException
- if it the method disableConnectionOperations has been called before.
And channel's open/close operations can't be called directly.java.lang.InterruptedException
- in case the open operation was interrupted.DuplexChannel.open()
public void beginOpen() throws ProtocolException
DuplexChannel
beginOpen
in interface AsyncChannel
beginOpen
in class DuplexChannel
DisabledMethodException
- if it the method disableConnectionOperations has been called before.
And channel's open/close operations can't be called directly.ProtocolException
- in case of problems establishing connectionpublic java.util.concurrent.Future<ChannelOpenedEvent> openAsync(java.lang.Long timeout)
DuplexChannel
openAsync
in class DuplexChannel
timeout
- it specifies channel opening timeout in milliseconds.DisabledMethodException
- if it the method disableConnectionOperations has been called before.
And channel's open/close operations can't be called directly.public <A> void openAsync(long timeout, CompletionHandler<java.util.EventObject,A> handler, A attachment)
AsyncChannelOperations
openAsync
in interface AsyncChannelOperations
openAsync
in class DuplexChannel
timeout
- operation timeout in milliseconds. Timeout will cancel the opening.handler
- success/fail result handling.public void close(boolean force) throws ProtocolException, java.lang.InterruptedException, java.lang.IllegalStateException
DuplexChannel
close
in class DuplexChannel
force
- if this flag is true then sending messages from queue will be canceled and channel will be closed immediatelyDisabledMethodException
- if it the method disableConnectionOperations has been called before.
And channel's open/close operations can't be called directly.ProtocolTimeoutException
- if channel wasn't closed for the specified time (when force == false)ProtocolException
- In the case of an unrecoverable protocol error. Client applications should not
try to deal with these exceptions, except for logging or displaying to users or technical administrators.
Check the exception cause for more details.java.lang.InterruptedException
- in case the close operation was interrupted.java.lang.IllegalStateException
- Exception will not be thrown in current implementation even if the channel is closed.public void close(long timeout) throws ProtocolException, java.lang.InterruptedException, java.lang.IllegalStateException
DuplexChannel
close
in interface Channel
close
in class DuplexChannel
timeout
- time in millisecondsDisabledMethodException
- if it the method disableConnectionOperations has been called before.
And channel's open/close operations can't be called directly.ProtocolTimeoutException
- if channel wasn't closed for the specified timeProtocolException
- In the case of an unrecoverable protocol error. Client applications should not
try to deal with these exceptions, except for logging or displaying to users or technical administrators.
Check the exception cause for more details.java.lang.InterruptedException
- in case the close operation was interrupted.java.lang.IllegalStateException
- exception will not be thrown in current implementation.public void beginClose() throws java.lang.IllegalStateException
DuplexChannel
beginClose
in interface AsyncChannel
beginClose
in class DuplexChannel
java.lang.IllegalStateException
- Exception will not be thrown in current implementation even if the channel is closed.public <A> void closeAsync(long timeout, CompletionHandler<ChannelClosedEvent,A> handler, A attachment)
AsyncChannelOperations
closeAsync
in interface AsyncChannelOperations
closeAsync
in class DuplexChannel
timeout
- operation timeout in milliseconds.
Timeout do not cancel the closing and do not close forcly the channel.handler
- success/fail result handling.DisabledMethodException
- if it the method disableConnectionOperations has been called before.
And channel's open/close operations can't be called directly.public java.util.concurrent.Future<ChannelClosedEvent> closeAsync()
DuplexChannel
Note: It hasn't related with the channel timeout. Use the future.get() with a timeout instead.
closeAsync
in class DuplexChannel
DisabledMethodException
- if it the method disableConnectionOperations has been called before.
And channel's open/close operations can't be called directly.protected void onOpen() throws ProtocolException
DuplexChannel
onOpen
in class DuplexChannel
ProtocolException
- if there are problems during
post open operations (e.g. registration)protected void onSend(Message message) throws ProtocolException
DuplexChannel
onSend
in class DuplexChannel
message
- Message to modifyProtocolException
- In the case of an unrecoverable protocol error. Client applications should not
try to deal with these exceptions, except for logging or displaying to users or technical administrators.
Check the exception cause for more details.protected void onReceiveMessage(Message msg)
DuplexChannel
onReceiveMessage
in class DuplexChannel
msg
- received message@Deprecated protected void setRegistrationHandler(ClientChannel.RegistrationHandler handler)
public void open(long timeout) { setRegistrationHandler(new MyHandler()); super.open(timeout); }
handler
- registration handlerClientChannel.ClientHandshakeStep
,
ClientChannel.BasicClientHandshakeStep
,
setHandshakePhase(ClientHandshakeStep)
protected void setHandshakePhase(ClientChannel.ClientHandshakeStep handshakeStart)
handshakeStart
- registration procedure entry point.ClientChannel.ClientHandshakeStep
,
ClientChannel.BasicClientHandshakeStep
protected void setHandshakeFinished(java.lang.Throwable exception)
public void fireUnsolicitedEvents()
@Deprecated protected Message submitRegMessage(Message regMessage) throws ProtocolException, java.lang.InterruptedException
regMessage
- registration message (from RegistrationHandler)null
in the following cases:
ProtocolException
- in the case of an unrecoverable protocol error. Client applications should not
try to deal with these exceptions, except for logging or displaying to users or technical administrators.
Check the exception cause for more details.java.lang.InterruptedException
- thread is interrupted waiting for response.protected ProtocolException getOpenTimeoutException(long timeout)
getOpenTimeoutException
in class DuplexChannel
timeout
- timeout was used to waitpublic ConnectionOperations disableConnectionOperations()
It disable all open operation in the channel through the channel. After call of the method there is only one possibility to open the channel through the returned AsyncOpen implementation. The method can be called once. The following calls will throw DisabledMethodException
DisabledMethodException
- if it has been called before.@Deprecated public AsyncInvoker getInvoker()
getInvoker
in class AbstractChannel
Send comments on this topicTechpubs.webadmin@genesys.com.
Document version: 9.0.006.00
Copyright © 2006–2019 Genesys Telecommunications Laboratories, Inc. All rights reserved.