Platform SDK Java 8.5 API Reference

com.genesyslab.platform.openmedia.protocol
Class InteractionServerProtocol

java.lang.Object
  extended by com.genesyslab.platform.commons.protocol.AbstractChannel
      extended by com.genesyslab.platform.commons.protocol.DuplexChannel
          extended by com.genesyslab.platform.commons.protocol.ClientChannel
              extended by com.genesyslab.platform.openmedia.protocol.InteractionServerProtocol
All Implemented Interfaces:
AsyncChannel, AsyncChannelOperations, AsyncInvokerSupport, Channel, ChannelListenerSupport, ConfigurationSupport, ConnectionInvokerSupport, EndpointSupport, InputChannel, InterceptorSupport, LogMessageFilterSupport, MessageReceiver, MessageReceiverManagement, OutputChannel, Protocol, ProtocolDescriptionSupport, Receiver, ReceiverManagement, RequestChannel, InteractionServerProtocolHandshakeOptions

@ProtocolDescription.Tag(sdkName="OpenMedia",
                         protocolName="InteractionServer")
public class InteractionServerProtocol
extends ClientChannel
implements InteractionServerProtocolHandshakeOptions

Use an InteractionServerProtocol object to establish communication between an agent application (or other client application) and Interaction Server.

For example, if you wanted to write an agent-facing application to handle Open Media interactions, you could set up an InteractionServerProtocol object and establish communication with the server in this way:

   InteractionServerProtocol interactionServerProtocol =
         new InteractionServerProtocol(
             new Endpoint(
                   endpointName,
                   interactionServerHost,
                   interactionServerPort));
   interactionServerProtocol.setClientType(InteractionClient.AgentApplication);
   interactionServerProtocol.open();
 
When you were finished communicating with the server, you could close the channel like this:
   interactionServerProtocol.close();
 
Here is a sample of how to open a connection to Interaction Server and create a new interaction with attached data:
   InteractionServerProtocol interactionServerProtocol =
         new InteractionServerProtocol(
             new Endpoint("InteractionServer", host, port));

   interactionServerProtocol.setClientName("EntityListener");
   interactionServerProtocol.
         setClientType(InteractionClient.MediaServer);

   KeyValueCollection userData =
         new KeyValueCollection();

   userData.addObject("crmactivityid", activityid);
   userData.addObject("crmactivitytype", activitytype);

   try {
       interactionServerProtocol.open();

       RequestSubmit requestSubmit = RequestSubmit.create(
             interactionServerProtocol.getProxyId(),
             null,
             null,
             inboundQueue,
             tenantID,
             "crmemail",
             "Inbound",
             "InboundNew",
             true,
             new Date(),
             userData,
             null,
             inQueues,
             outQueues);

       Message response =
             interactionServerProtocol.request(requestSubmit);
       writeToLog("Response: " + response.messageName());
   } catch(Exception exception) {
       writeToLog(
             "Exception while sending request to interaction server: "
             + exception.getMessage());
   }
 

Note: Starting from Platform SDK 8.5.0 version, main protocol channel classes (including InteractionServerProtocol) are no longer "final".
It helps with applications unit testing. At the same time it opens access and allows to override protocols internal protected staff from custom child classes.
Changes or extensions of the protocols functionality in child classes must be done very carefully with clear understanding of affected components and functionality.
Also, protected PSDK methods and elements are not a part of public API, and may be a subject for changes without special notice. So, application, which uses or overrides internal/protected staff, may have compatibility issues on PSDK update.


Nested Class Summary
 
Nested classes/interfaces inherited from class com.genesyslab.platform.commons.protocol.ClientChannel
ClientChannel.BasicClientHandshakeStep, ClientChannel.ClientHandshakeStep, ClientChannel.RegistrationHandler, ClientChannel.SimpleRegistrationHandler
 
Nested classes/interfaces inherited from class com.genesyslab.platform.commons.protocol.AbstractChannel
AbstractChannel.AsyncErrorNotifier
 
Field Summary
static ProtocolDescription PROTOCOL_DESCRIPTION
          Protocol signature (sdk and name) for this Channel.
 
Fields inherited from class com.genesyslab.platform.commons.protocol.DuplexChannel
messageFilter
 
Fields inherited from interface com.genesyslab.platform.commons.protocol.Receiver
DEF_INPUT_SIZE
 
Fields inherited from interface com.genesyslab.platform.commons.protocol.Channel
DEFAULT_TIMEOUT, INFINITE_TIMEOUT
 
Constructor Summary
InteractionServerProtocol()
          Creates channel to Interaction server.
InteractionServerProtocol(Endpoint endpoint)
          Creates channel to Interaction server.
InteractionServerProtocol(Endpoint endpoint, long timeout)
          Creates channel to Interaction server.
 
Method Summary
 java.lang.Integer createReference()
          Creates the next reference.
 java.lang.String getClientName()
          Returns the name of a client.
 InteractionClient getClientType()
          Returns the type of a client.
 java.lang.String getMediaType()
          Returns the type of media.
 java.lang.Integer getProxyId()
          Returns the proxy id.
 KeyValueCollection getRegistrationExtensions()
          Returns extended parameters of registration.
 InteractionServerContext getServerContext()
          Returns server context.
protected  void onClose(ConnectionClosedEvent event)
           
protected  void onOpen()
          This method is called when channel is opened and just about to call event handler.
 void setClientName(java.lang.String nameOfClient)
          Sets the name of a client.
 void setClientType(InteractionClient typeOfClient)
          Sets the type of a client.
 void setMediaType(java.lang.String value)
          Sets the type of media.
 void setProxyId(java.lang.Integer idOfProxy)
          Sets the id of the proxy.
 void setRegistrationExtensions(KeyValueCollection registrationExt)
          Sets extended parameters of registration.
 
Methods inherited from class com.genesyslab.platform.commons.protocol.ClientChannel
beginClose, beginOpen, beginRequest, close, close, closeAsync, closeAsync, disableConnectionOperations, doBeginRequest, doBeginRequest, doRequest, endRequest, endRequest, fireUnsolicitedEvents, getCopyResponse, getInvoker, getOpenTimeoutException, getReferenceBuilder, onReceiveMessage, onSend, onUnexpectedHandshakeMessage, open, openAsync, openAsync, request, request, requestAsync, requestAsync, setAddressResolver, setAddressResolverParams, setAddressResolverParams, setCopyResponse, setEndpoint, setHandshakeFinished, setHandshakePhase, setHandshakeUnsolicitedEventsPassLimit, setRegistrationHandler, setState, submitRegMessage, throwOnUnReferenceableRequest
 
Methods inherited from class com.genesyslab.platform.commons.protocol.DuplexChannel
addListener, applyConfiguration, cancelCloseTimeout, cancelOpenTimeout, clearInput, close, closeAsync, createChannelClosedEvent, createConnection, createConnectionClosedEvent, doBeginClose, doClose, doSend, downgradeConnection, getDefaultRestriction, getEnpointPrefixInfo, getInputSize, getInterceptor, getLocalEndPoint, getLocalEndpointInfo, getLogMessageFilter, getProtocolDescription, getProtocolFactory, getProtocolId, getRemoteEndPoint, getTimeoutException, initPackager, isMessageAllowed, notifyWithObject, 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
 
Methods inherited from class com.genesyslab.platform.commons.protocol.AbstractChannel
addChannelListener, configure, connectionContext, copyTLSSettings, fireClosed, fireErrorEvent, fireErrorEvent, generateChannelId, getChannelId, getConfiguration, getDefaultInvoker, getEndpoint, getListenerHelper, getState, getStateMods, getTimeout, internal, onSetEndpoint, releaseDefaultInvoker, removeChannelListener, setConfiguration, setInvoker, setServerContext, setState, setTimeout, throwNotClosed, throwNotOpened, throwNotOpenedOnClose, throwNotOpenedOnSend, throwNull, throwNullEndpoint
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.genesyslab.platform.commons.protocol.Protocol
getProtocolId
 
Methods inherited from interface com.genesyslab.platform.commons.protocol.InputChannel
setMessageHandler
 
Methods inherited from interface com.genesyslab.platform.commons.protocol.MessageReceiver
receive, receive
 
Methods inherited from interface com.genesyslab.platform.commons.protocol.Receiver
clearInput, getInputSize, releaseReceivers, setInputSize
 
Methods inherited from interface com.genesyslab.platform.commons.protocol.OutputChannel
addListener, removeListener, send
 
Methods inherited from interface com.genesyslab.platform.commons.protocol.Channel
close, getTimeout, open, 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.InterceptorSupport
getInterceptor
 
Methods inherited from interface com.genesyslab.platform.commons.protocol.MessageReceiverManagement
setReceiver
 
Methods inherited from interface com.genesyslab.platform.commons.protocol.ReceiverManagement
resetReceiver
 
Methods inherited from interface com.genesyslab.platform.commons.protocol.ConfigurationSupport
configure, getConfiguration
 
Methods inherited from interface com.genesyslab.platform.commons.protocol.EndpointSupport
getEndpoint
 
Methods inherited from interface com.genesyslab.platform.commons.protocol.ProtocolDescriptionSupport
getProtocolDescription
 
Methods inherited from interface com.genesyslab.platform.commons.protocol.AsyncInvokerSupport
setInvoker
 
Methods inherited from interface com.genesyslab.platform.commons.protocol.ConnectionInvokerSupport
setConnectionInvoker
 

Field Detail

PROTOCOL_DESCRIPTION

public static final ProtocolDescription PROTOCOL_DESCRIPTION
Protocol signature (sdk and name) for this Channel.

Constructor Detail

InteractionServerProtocol

public InteractionServerProtocol(Endpoint endpoint,
                                 long timeout)
Creates channel to Interaction server.

Parameters:
endpoint - Parameters of the connection to create
timeout - Timeout to wait for message (in milliseconds)

InteractionServerProtocol

public InteractionServerProtocol(Endpoint endpoint)
Creates channel to Interaction server.

Parameters:
endpoint - Parameters of the connection to create

InteractionServerProtocol

public InteractionServerProtocol()
Creates channel to Interaction server.

Method Detail

createReference

public java.lang.Integer createReference()
Creates the next reference.

Returns:
The next reference value

getClientType

public InteractionClient getClientType()
Returns the type of a client.

Specified by:
getClientType in interface InteractionServerProtocolHandshakeOptions
Returns:
type of client
See Also:
setClientType(InteractionClient)

setClientType

public void setClientType(InteractionClient typeOfClient)
Sets the type of a client.

Specified by:
setClientType in interface InteractionServerProtocolHandshakeOptions
Parameters:
typeOfClient - type of client

getClientName

public java.lang.String getClientName()
Returns the name of a client.

Specified by:
getClientName in interface InteractionServerProtocolHandshakeOptions
Returns:
name of client
See Also:
setClientName(String)

setClientName

public void setClientName(java.lang.String nameOfClient)
Sets the name of a client.

Specified by:
setClientName in interface InteractionServerProtocolHandshakeOptions
Parameters:
nameOfClient - name of client

getMediaType

public java.lang.String getMediaType()
Returns the type of media. Used when client type is 'MediaServer'.

Specified by:
getMediaType in interface InteractionServerProtocolHandshakeOptions
Returns:
type of media or null
See Also:
setMediaType(String)

setMediaType

public void setMediaType(java.lang.String value)
Sets the type of media. Used when client type is 'MediaServer'.

Specified by:
setMediaType in interface InteractionServerProtocolHandshakeOptions
Parameters:
value - type of media

getProxyId

public java.lang.Integer getProxyId()
Returns the proxy id. Used when client type is 'Proxy'. After connection is opened actual proxy id can be obtained from server context.

Specified by:
getProxyId in interface InteractionServerProtocolHandshakeOptions
Returns:
id of proxy or null
See Also:
setProxyId(Integer), getServerContext(), InteractionServerContext.getProxyId()

setProxyId

public void setProxyId(java.lang.Integer idOfProxy)
Sets the id of the proxy. Used when client type is 'Proxy'. After connection is opened actual proxy id can be obtained from server context.

Specified by:
setProxyId in interface InteractionServerProtocolHandshakeOptions
Parameters:
idOfProxy - id of the proxy

getRegistrationExtensions

public KeyValueCollection getRegistrationExtensions()
Returns extended parameters of registration. After connection is opened actual parameters can be obtained from server context.

Specified by:
getRegistrationExtensions in interface InteractionServerProtocolHandshakeOptions
Returns:
registration extensions
See Also:
setRegistrationExtensions(KeyValueCollection), getServerContext(), InteractionServerContext.getRegistrationExtensions()

setRegistrationExtensions

public void setRegistrationExtensions(KeyValueCollection registrationExt)
Sets extended parameters of registration. After connection is opened actual parameters can be obtained from server context.

Specified by:
setRegistrationExtensions in interface InteractionServerProtocolHandshakeOptions
Parameters:
registrationExt - registration extensions
See Also:
getRegistrationExtensions(), getServerContext(), InteractionServerContext.getRegistrationExtensions()

getServerContext

public InteractionServerContext getServerContext()
Returns server context. Context groups server specific data, which is received from server during connection sequence. When there is no connection to server this method returns null and previous context is considered invalid.

Overrides:
getServerContext in class AbstractChannel
Returns:
server context

onOpen

protected void onOpen()
               throws ProtocolException
Description copied from class: DuplexChannel
This method is called when channel is opened and just about to call event handler. You usually will need to add some logic here and call super.onOpen() at the end of your method. Please note, that calling super.onOpen() on the thread other then open() was called will most probably result in deadlock for some scenarios (like calling close() inside of onChannelOpened())

Overrides:
onOpen in class ClientChannel
Throws:
ProtocolException - if there are problems during post open operations (e.g. registration)

onClose

protected void onClose(ConnectionClosedEvent event)
Overrides:
onClose in class DuplexChannel

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.