Platform SDK Java 8.5 API Reference

com.genesyslab.platform.webmedia.protocol
Class FlexChatProtocol

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.webmedia.protocol.WebmediaChannel
                  extended by com.genesyslab.platform.webmedia.protocol.OptionalRegistrationChannel
                      extended by com.genesyslab.platform.webmedia.protocol.FlexChatProtocol
All Implemented Interfaces:
AsyncChannel, AsyncChannelOperations, AsyncInvokerSupport, Channel, ChannelListenerSupport, ConfigurationSupport, ConnectionInvokerSupport, EndpointSupport, InputChannel, InterceptorSupport, LogMessageFilterSupport, MessageReceiver, MessageReceiverManagement, OutputChannel, Protocol, ProtocolDescriptionSupport, Receiver, ReceiverManagement, RequestChannel, FlexChatProtocolHandshakeOptions

@ProtocolDescription.Tag(sdkName="WebMedia",
                         protocolName="FlexChat")
public class FlexChatProtocol
extends OptionalRegistrationChannel
implements FlexChatProtocolHandshakeOptions

By default, channel has enabled AutoRegister mode. If channel going to be used for more than one chat server client, you should disable AutoRegister mode and explicitly login every client:


 flexChat.setAutoRegister(false);
 flexChat.open();
 ... 
 Message response = flexChat.request(RequestLogin.create(nickName, timeZone, userData));
 if(response instanceof EventStatus) {
   EventStatus status = (EventStatus)response;
   String userId = status.getUserId();
   String secureKey = status.getSecureKey();
 }
 ...
 
Explicitly specify userId/secureKey in further interactions:

 Message response = flexChat.request(RequestJoin.create(userId, secureKey, ...));
 
Protocol object can also auto store userId/secureKey and automatically update Request fields, but this have sense only for single chat server client. When AutoRegister mode enabled:

These UserId and SecureKey properties will be set automatically in each user request by channel, if they are not set manually.


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
           
 
Fields inherited from class com.genesyslab.platform.webmedia.protocol.WebmediaChannel
OPTION_NAME_ILLEGAL_UNICODE_CHARS_REPLACEMENT, OPTION_NAME_REPLACE_ILLEGAL_UNICODE_CHARS, OPTION_NAME_TARGET_XML_VERSION
 
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
FlexChatProtocol()
          Creates instance of FlexChatProtocol.
FlexChatProtocol(Endpoint endpoint)
          Creates instance of FlexChatProtocol.
FlexChatProtocol(Endpoint endpoint, long timeout)
          Creates instance of FlexChatProtocol.
FlexChatProtocol(Endpoint endpoint, ReferenceBuilder refBuilder, long timeout)
          Creates instance of FlexChatProtocol.
 
Method Summary
protected  com.genesyslab.platform.commons.connection.impl.xml.ProtocolDialect getDialect()
           
protected  ClientChannel.ClientHandshakeStep getHandshakeStart()
          This virtual method returns initial handshake step for this channel.
 java.lang.String getSecureKey()
          Optional, if set with UserId, channel will not send RequestLogin message during opening.
 FlexChatServerContext getServerContext()
           
 java.lang.Integer getTimeZoneOffset()
          Optional, timezone offset.
 KeyValueCollection getUserData()
          Optional, used for user identification in UCS (Universal Contact Server).
 java.lang.String getUserId()
          Optional, if set with SecureKey, channel will not send RequestLogin message during opening.
 java.lang.String getUserNickname()
          Optional, but very desirable for login during channel Open.
 boolean isAutoRegister()
          Returns flag for automatic client registration request on connection open.
By default it is enabled, but sometimes it may be required to do some other operations before client registration request, or there is a need to create custom registration request.
In this case user may disable automatic registration and later (after the connection opened) send own registration request.
protected  void onClose(ConnectionClosedEvent event)
           
protected  void onOpen()
          This method is called when channel is opened and just about to call event handler.
protected  void onReceiveMessage(Message message)
          Gives to subclass a chance to perform some operations on incoming message arrival before delivering it to connection user code.
 void onSend(Message message)
          Gives to subclass a chance to modify message before sending it to remote party.
 void setAutoRegister(boolean autoRegister)
          Sets flag for automatic client registration request on connection open.
By default it is enabled, but sometimes it may be required to do some other operations before client registration request, or there is a need to create custom registration request.
In this case user may disable automatic registration and later (after the connection opened) send own registration request.
 void setSecureKey(java.lang.String secureKey)
          Optional, if set with UserId, channel will not send RequestLogin message during opening.
 void setTimeZoneOffset(int timeZoneOffset)
          Optional, timezone offset.
 void setTimeZoneOffset(java.lang.Integer timeZoneOffset)
          Optional, timezone offset.
 void setUserData(KeyValueCollection userData)
          Optional, used for user identification in UCS (Universal Contact Server).
 void setUserId(java.lang.String userId)
          Optional, if set with SecureKey, channel will not send RequestLogin message during opening.
 void setUserNickname(java.lang.String userNickname)
          Optional, but very desirable for login during channel Open.
 
Methods inherited from class com.genesyslab.platform.webmedia.protocol.WebmediaChannel
applyConfiguration, createConnection, lookupConnectionParameter
 
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, 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, cancelCloseTimeout, cancelOpenTimeout, clearInput, close, closeAsync, createChannelClosedEvent, 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
Constructor Detail

FlexChatProtocol

public FlexChatProtocol(Endpoint endpoint,
                        ReferenceBuilder refBuilder,
                        long timeout)
Creates instance of FlexChatProtocol.

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

FlexChatProtocol

public FlexChatProtocol(Endpoint endpoint,
                        long timeout)
Creates instance of FlexChatProtocol.

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

FlexChatProtocol

public FlexChatProtocol(Endpoint endpoint)
Creates instance of FlexChatProtocol.

Parameters:
endpoint - Parameters of the connection to create

FlexChatProtocol

public FlexChatProtocol()
Creates instance of FlexChatProtocol.

Method Detail

getTimeZoneOffset

public java.lang.Integer getTimeZoneOffset()
Optional, timezone offset.

Specified by:
getTimeZoneOffset in interface FlexChatProtocolHandshakeOptions
Returns:
timezone offset or null

setTimeZoneOffset

public void setTimeZoneOffset(java.lang.Integer timeZoneOffset)
Optional, timezone offset.

Specified by:
setTimeZoneOffset in interface FlexChatProtocolHandshakeOptions
Parameters:
timeZoneOffset - timezone offset

setTimeZoneOffset

public void setTimeZoneOffset(int timeZoneOffset)
Optional, timezone offset.

Specified by:
setTimeZoneOffset in interface FlexChatProtocolHandshakeOptions
Parameters:
timeZoneOffset - timezone offset

getUserData

public KeyValueCollection getUserData()
Optional, used for user identification in UCS (Universal Contact Server).

Specified by:
getUserData in interface FlexChatProtocolHandshakeOptions
Returns:
user data or null

setUserData

public void setUserData(KeyValueCollection userData)
Optional, used for user identification in UCS (Universal Contact Server).

Specified by:
setUserData in interface FlexChatProtocolHandshakeOptions
Parameters:
userData - user data

getUserNickname

public java.lang.String getUserNickname()
Optional, but very desirable for login during channel Open. It will be used for user display name. This field will be ignored in case of setting UserId and SecureKey.

Specified by:
getUserNickname in interface FlexChatProtocolHandshakeOptions
Returns:
user nickname or null

setUserNickname

public void setUserNickname(java.lang.String userNickname)
Optional, but very desirable for login during channel Open. It will be used for user display name. This field will be ignored in case of setting UserId and SecureKey.

Specified by:
setUserNickname in interface FlexChatProtocolHandshakeOptions
Parameters:
userNickname - user nickname

getSecureKey

public java.lang.String getSecureKey()
Optional, if set with UserId, channel will not send RequestLogin message during opening.

Specified by:
getSecureKey in interface FlexChatProtocolHandshakeOptions
Returns:
secure key or null

setSecureKey

public void setSecureKey(java.lang.String secureKey)
Optional, if set with UserId, channel will not send RequestLogin message during opening.

Specified by:
setSecureKey in interface FlexChatProtocolHandshakeOptions
Parameters:
secureKey - secure key

getUserId

public java.lang.String getUserId()
Optional, if set with SecureKey, channel will not send RequestLogin message during opening.

Specified by:
getUserId in interface FlexChatProtocolHandshakeOptions
Returns:
user id or null

setUserId

public void setUserId(java.lang.String userId)
Optional, if set with SecureKey, channel will not send RequestLogin message during opening.

Specified by:
setUserId in interface FlexChatProtocolHandshakeOptions
Parameters:
userId - user id

isAutoRegister

public boolean isAutoRegister()
Returns flag for automatic client registration request on connection open.
By default it is enabled, but sometimes it may be required to do some other operations before client registration request, or there is a need to create custom registration request.
In this case user may disable automatic registration and later (after the connection opened) send own registration request.

Specified by:
isAutoRegister in interface FlexChatProtocolHandshakeOptions
Overrides:
isAutoRegister in class OptionalRegistrationChannel
Returns:
flag for automatic client registration request allowing
See Also:
setAutoRegister(boolean), RequestLogin

setAutoRegister

public void setAutoRegister(boolean autoRegister)
Sets flag for automatic client registration request on connection open.
By default it is enabled, but sometimes it may be required to do some other operations before client registration request, or there is a need to create custom registration request.
In this case user may disable automatic registration and later (after the connection opened) send own registration request.

Specified by:
setAutoRegister in interface FlexChatProtocolHandshakeOptions
Overrides:
setAutoRegister in class OptionalRegistrationChannel
Parameters:
autoRegister - flag for automatic client registration request allowing
See Also:
RequestLogin

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 OptionalRegistrationChannel
Throws:
ProtocolException - if there are problems during post open operations (e.g. registration)

onClose

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

getServerContext

public FlexChatServerContext getServerContext()
Overrides:
getServerContext in class AbstractChannel

onSend

public void onSend(Message message)
            throws ProtocolException
Description copied from class: DuplexChannel
Gives to subclass a chance to modify message before sending it to remote party.

Overrides:
onSend in class ClientChannel
Parameters:
message - Message to modify
Throws:
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.

onReceiveMessage

protected void onReceiveMessage(Message message)
Description copied from class: DuplexChannel
Gives to subclass a chance to perform some operations on incoming message arrival before delivering it to connection user code. We don't use AsyncInvoker here, because the message handling in this class probably doesn't worth it - this method is quick and shouldn't load connection thread too much. But if this method is overridden in some classes and contains some long-running logic, consider using AsyncInvoker

Overrides:
onReceiveMessage in class ClientChannel
Parameters:
message - received message

getDialect

protected com.genesyslab.platform.commons.connection.impl.xml.ProtocolDialect getDialect()
Specified by:
getDialect in class WebmediaChannel

getHandshakeStart

protected ClientChannel.ClientHandshakeStep getHandshakeStart()
Description copied from class: OptionalRegistrationChannel
This virtual method returns initial handshake step for this channel. Used in onOpen() as variable part of "template" pattern.

Specified by:
getHandshakeStart in class OptionalRegistrationChannel
Returns:
handshake initial registration step

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.