Platform SDK Java 8.5 API Reference

com.genesyslab.platform.openmedia.protocol
Class InteractionServerProtocolListener

java.lang.Object
  extended by com.genesyslab.platform.commons.protocol.AbstractChannel
      extended by com.genesyslab.platform.commons.protocol.ServerChannel
          extended by com.genesyslab.platform.openmedia.protocol.InteractionServerProtocolListener
All Implemented Interfaces:
AsyncChannel, AsyncInvokerSupport, Channel, ChannelListenerSupport, ConfigurationSupport, ConnectionInvokerSupport, EndpointSupport, OutputChannel, ProtocolDescriptionSupport, Receiver, ReceiverManagement, RequestReceiver, RequestReceiverManagement, ResponseChannel

public class InteractionServerProtocolListener
extends ServerChannel

Use 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.


Nested Class Summary
 
Nested classes/interfaces inherited from class com.genesyslab.platform.commons.protocol.AbstractChannel
AbstractChannel.AsyncErrorNotifier
 
Field Summary
 
Fields inherited from interface com.genesyslab.platform.commons.protocol.Channel
DEFAULT_TIMEOUT, INFINITE_TIMEOUT
 
Fields inherited from interface com.genesyslab.platform.commons.protocol.Receiver
DEF_INPUT_SIZE
 
Constructor Summary
InteractionServerProtocolListener(Endpoint endpoint)
           
 
Method Summary
 
Methods inherited from class com.genesyslab.platform.commons.protocol.ServerChannel
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
 
Methods inherited from class com.genesyslab.platform.commons.protocol.AbstractChannel
addChannelListener, configure, connectionContext, copyTLSSettings, createChannelClosedEvent, fireClosed, fireErrorEvent, fireErrorEvent, generateChannelId, getChannelId, getConfiguration, getDefaultInvoker, getEndpoint, getEnpointPrefixInfo, getInvoker, getListenerHelper, getLocalEndpointInfo, getServerContext, getState, getStateMods, getTimeout, internal, onFireClosed, onFireErrorEvent, onFireOpened, onSetEndpoint, releaseDefaultInvoker, removeChannelListener, setConfiguration, setConnectionInvoker, setEndpoint, setInvoker, setServerContext, setState, setState, setTimeout, throwNotClosed, throwNotOpened, throwNotOpenedOnClose, throwNotOpenedOnSend, throwNull, throwNullEndpoint
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.genesyslab.platform.commons.protocol.Channel
getTimeout, setTimeout
 
Methods inherited from interface com.genesyslab.platform.commons.protocol.AsyncChannel
getState
 
Methods inherited from interface com.genesyslab.platform.commons.protocol.ChannelListenerSupport
addChannelListener, removeChannelListener
 
Methods inherited from interface com.genesyslab.platform.commons.protocol.EndpointSupport
getEndpoint, setEndpoint
 
Methods inherited from interface com.genesyslab.platform.commons.protocol.ConfigurationSupport
configure, getConfiguration
 

Constructor Detail

InteractionServerProtocolListener

public InteractionServerProtocolListener(Endpoint endpoint)

Platform SDK Java 8.5 API Reference

Send comments on this topicTechpubs.webadmin@genesys.com.
Document version: 8.5.302.00
Copyright © 2006–2017 Genesys Telecommunications Laboratories, Inc. All rights reserved.