AsyncChannel
, AsyncInvokerSupport
, Channel
, ChannelListenerSupport
, ConfigurationSupport
, ConnectionInvokerSupport
, EndpointSupport
, OutputChannel
, ProtocolDescriptionSupport
, Receiver
, ReceiverManagement
, RequestReceiver
, RequestReceiverManagement
, ResponseChannel
public class InteractionServerProtocolListener extends ServerChannel
InteractionServerProtocolListener
object as a server for InteractionServerProtocol
.
// Example of using InteractionServerProtocolListener
.
import com.genesyslab.platform.openmedia.protocol.InteractionServerProtocol;
import com.genesyslab.platform.openmedia.protocol.InteractionServerProtocolListener;
import com.genesyslab.platform.openmedia.protocol.interactionserver.events.EventAck;
import com.genesyslab.platform.openmedia.protocol.interactionserver.requests.RequestRegisterClient;
import com.genesyslab.platform.commons.protocol.Message;
import com.genesyslab.platform.commons.protocol.Endpoint;
import com.genesyslab.platform.commons.protocol.Referenceable;
import com.genesyslab.platform.commons.protocol.RequestContext;
import com.genesyslab.platform.commons.protocol.WildcardEndpoint;
import com.genesyslab.platform.commons.protocol.ProtocolException;
import com.genesyslab.platform.commons.protocol.ClientRequestHandler;
public class testIxn {
public static void main(final String[] args)
throws ProtocolException, IllegalStateException, InterruptedException {
final int PORT = 11111;
final InteractionServerProtocolListener server = new InteractionServerProtocolListener(new WildcardEndpoint(PORT));
server.setClientRequestHandler(new ClientRequestHandler() {
public void processRequest(final RequestContext requestContext) {
Message msg = requestContext.getRequestMessage();
Message response = null;
Object refId = null;
if (msg instanceof Referenceable) {
refId = ((Referenceable) msg).retreiveReference();
}
if (msg != null) {
if (msg.messageId() == RequestRegisterClient.ID) {
RequestRegisterClient request = (RequestRegisterClient) msg;
EventAck event = EventAck.create();
event.setProxyClientId(1);
response = event;
} else if (msg.messageId() == Request*.ID) { // handle some request
// ...
// create response
}
}
if (response != null) {
if (refId != null && response instanceof Referenceable) {
((Referenceable) response).updateReference(refId);
}
try {
requestContext.respond(response);
} catch (final ProtocolException e) {
e.printStackTrace();
}
}
}
});
server.open();
InteractionServerProtocol client = new InteractionServerProtocol(new Endpoint("localhost", PORT));
client.open();
// create "some request":
Request* request = Request*.create();
request.set*(*);
Message response = client.request(request);
// ...
client.close();
server.close();
}
}
Note, that ServerChannel
adds ADDP support for incoming connections by default, if no protocol name option is specified.
The AddpInterceptor.ACTIVE_KEY
option always set to false, because it is client channel responsibility to initiate ADDP.AbstractChannel.AsyncErrorNotifier
DEFAULT_TIMEOUT, INFINITE_TIMEOUT
DEF_INPUT_SIZE
Constructor | Description |
---|---|
InteractionServerProtocolListener(Endpoint endpoint) |
addChannelListener, configure, connectionContext, copyTLSSettings, createChannelClosedEvent, fireClosed, fireErrorEvent, fireErrorEvent, generateChannelId, getChannelId, getConfiguration, getDefaultInvoker, getEndpoint, getEnpointPrefixInfo, getInvoker, getListenerHelper, getLocalEndpointInfo, getServerContext, getState, getStateMods, getTimeout, getTimer, internal, onFireClosed, onFireErrorEvent, onFireOpened, onSetEndpoint, releaseDefaultInvoker, removeChannelListener, setConfiguration, setConnectionInvoker, setEndpoint, setInvoker, setServerContext, setState, setState, setTimeout, throwNotClosed, throwNotOpened, throwNotOpenedOnClose, throwNotOpenedOnSend, throwNull, throwNullEndpoint
getState
getTimeout, setTimeout
addChannelListener, removeChannelListener
configure, getConfiguration
getEndpoint, setEndpoint
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addListener, applyConfiguration, beginClose, beginOpen, clearInput, close, close, closeClientChannels, closeListener, getChannels, getInputSize, getLocalEndPoint, getProtocolDescription, getProtocolFactory, modifyNewChannel, open, open, receive, receive, receiveRequest, receiveRequest, releaseReceivers, removeListener, resetReceiver, send, sendToChannelsExcept, sendToChannelsExcept, setClientRequestHandler, setInputSize, setReceiver
public InteractionServerProtocolListener(Endpoint endpoint)
Send comments on this topicTechpubs.webadmin@genesys.com.
Document version: 9.0.006.00
Copyright © 2006–2019 Genesys Telecommunications Laboratories, Inc. All rights reserved.