com.echomine.net
Class HandshakeableSocketConnector

java.lang.Object
  extended by com.echomine.net.Connection
      extended by com.echomine.net.TimeableConnection
          extended by com.echomine.net.HandshakeableSocketConnector

public class HandshakeableSocketConnector
extends TimeableConnection

This class works similar to SocketConnector to add in handshaking capability. The event processing is as follows: connection starting, handshake called, connection established, handle called, connection closed.

See Also:
SocketConnector

Field Summary
 
Fields inherited from class com.echomine.net.Connection
listenerList
 
Constructor Summary
HandshakeableSocketConnector()
          Do-nothing constructor.
HandshakeableSocketConnector(HandshakeableSocketHandler socketHandler)
           
 
Method Summary
 void aconnect(ConnectionModel connectionModel)
          makes a connection asynchronously using internal socket handler.
 void aconnect(HandshakeableSocketHandler socketHandler, ConnectionModel connectionModel)
          makes a connection asynchronously.
 void connect(ConnectionModel connectionModel)
          Synchronous connect method using internal socket handler.
 void connect(HandshakeableSocketHandler socketHandler, ConnectionModel connectionModel)
          Synchronous connect method.
 HandshakeableSocketHandler getSocketHandler()
           
 void setSocketHandler(HandshakeableSocketHandler socketHandler)
          override parent to check and make sure the handler is a HandshakeableSocketHandler.
 
Methods inherited from class com.echomine.net.TimeableConnection
fireConnectionClosed, fireConnectionEstablished
 
Methods inherited from class com.echomine.net.Connection
addConnectionListener, fireConnectionStarting, fireConnectionStartingWithoutVeto, removeConnectionListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HandshakeableSocketConnector

public HandshakeableSocketConnector()
Do-nothing constructor. Usually used for multi-threading reuse of this instance since the Handler can be passed in as a parameter for connect().


HandshakeableSocketConnector

public HandshakeableSocketConnector(HandshakeableSocketHandler socketHandler)
Method Detail

connect

public void connect(ConnectionModel connectionModel)
             throws ConnectionFailedException
Synchronous connect method using internal socket handler. The method will return when handling of the connection is finished.

Throws:
ConnectionFailedException

connect

public void connect(HandshakeableSocketHandler socketHandler,
                    ConnectionModel connectionModel)
             throws ConnectionFailedException
Synchronous connect method. The method will return when handling of the connection is finished. This method will fire connection events at the appropriate time and call the handshake method at the appropriate time.

Throws:
ConnectionFailedException

aconnect

public void aconnect(ConnectionModel connectionModel)
makes a connection asynchronously using internal socket handler. This means that the method will be run in a separate thread and return control to the caller of the method immediately.


aconnect

public void aconnect(HandshakeableSocketHandler socketHandler,
                     ConnectionModel connectionModel)
makes a connection asynchronously. This means that the method will be run in a separate thread and return control to the caller of the method immediately. This method will fire connection events at the appropriate time and call the handshake method at the appropriate time.


getSocketHandler

public HandshakeableSocketHandler getSocketHandler()
Returns:
the socket handler associated with the connection

setSocketHandler

public void setSocketHandler(HandshakeableSocketHandler socketHandler)
override parent to check and make sure the handler is a HandshakeableSocketHandler.

Throws:
java.lang.IllegalArgumentException - if socket handler does not implement the right handler


Copyright © 2001-2005 Echomine. All Rights Reserved.