Platform SDK Java 8.5 API Reference

com.genesyslab.platform.commons.protocol
Interface ClientChannel.ClientHandshakeStep

All Known Implementing Classes:
ClientChannel.BasicClientHandshakeStep
Enclosing class:
ClientChannel

protected static interface ClientChannel.ClientHandshakeStep

Interface representing client side step of a protocol handshake procedure.

Client handshake procedure is handled in a state machine way, where "state" is an instance of ClientHandshakeStep.
A handshake procedure may consist of one or more "steps" which represent some registration iteration(s) like:

So, the usual handshake solution for particular is following:

Common client channel handshake machine logic schema is:

 @Override
 protected void onReceiveMessage(final Message msg) {
     if (handshakeState != null) {
         handshakeState = handshakeState.handleMessage(msg);
         if (handshakeState == null) {
             // handshake successfully finished
             finalyzeHandshake(); // switch channel from 'Opening' to 'Opened'
         }
     }
     ...
 }
 

See Also:
ClientChannel.BasicClientHandshakeStep, ClientChannel.setHandshakePhase(ClientHandshakeStep), ClientChannel.onOpen()

Method Summary
 Message getRegistrationRequest()
          This method is intended to be used from initState() to get a new instance of handshake request message.
 ClientChannel.ClientHandshakeStep handleMessage(Message event)
          This method handles incoming message assuming it is a server response for the request by initState().
It is responsible for the following operations: Check that the incoming message is a "successful" response to the request, extract store useful information like session id, server version, etc. If the message is an error message, it should throw appropriate exception. If the message is some acceptable unsolicited event, it may be passed through to user code. It returns null if handshake is successfully finished. It returns "self" reference to handle next incoming message with this state. It returns something like (new NextStep()).initState() to successfully pass this step and to switch to the next one.
 ClientChannel.ClientHandshakeStep initState()
          General goal of this method is to send the request message and get ready to handle server response with handleMessage(Message).
 

Method Detail

initState

ClientChannel.ClientHandshakeStep initState()
                                            throws ProtocolException
General goal of this method is to send the request message and get ready to handle server response with handleMessage(Message).

Several variations of a handshake step:

To get the request message before send, it uses virtual method getRegistrationRequest().

Returns:
step reference to wait for server response or null if there is no need to wait for any server response (handshake successfully finished).
Throws:
ProtocolException - in case of problem on send of the request message.
See Also:
getRegistrationRequest(), handleMessage(Message)

getRegistrationRequest

Message getRegistrationRequest()
                               throws ProtocolException
This method is intended to be used from initState() to get a new instance of handshake request message.

Returns:
new instance of the request message
Throws:
ProtocolException

handleMessage

ClientChannel.ClientHandshakeStep handleMessage(Message event)
                                                throws ProtocolException
This method handles incoming message assuming it is a server response for the request by initState().
It is responsible for the following operations:

Parameters:
event - incoming message from the server side.
Returns:
next state or null in case of successful handshake finish.
Throws:
ProtocolException - in case of handshake error or in case of problem on send of next request message.

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.