amber.client
Class SocketConnection

java.lang.Object
  |
  +--amber.client.SocketConnection
All Implemented Interfaces:
ConnectionModule, java.lang.Runnable

public class SocketConnection
extends java.lang.Object
implements ConnectionModule, java.lang.Runnable

This class implements the ConnectionModule interface. It handles the requirements for managing a standard socket connection to the remote server. If the parameters for this module are not set then the default fail overs are used.

This details the parameters and their values.

Component Parameters
NameTypeDescriptionDefault
SECUREbooleanWhether the connection should be secured (encrypted).0 (false)
SERVERSHAintThe SHA-1 digest of the RSA values held at the server. This is to avoid man-in-the-middle attacks of the secure connection.No default, no check on RSA validity is performed.
SERVERStringThe IP address of the Amber server.The IP address of the server which served the Web page.
PORTintThe port number to connect to at the remote server.21384 if not sercure or 21385 if secure.

Version:
1.0.0
Author:
Dr. David J. Knowles
See Also:
ConnectionModule, BaseComponent

Field Summary
protected  int clientType
           
protected  BaseComponent parent
           
protected  java.lang.String serverName
          The address of the Amber Server.
protected  int serverPort
          The port the Amber Server is listening on.
protected  java.lang.String sessionId
           
protected  java.net.Socket socket
           
 
Constructor Summary
SocketConnection()
          Default constructor.
 
Method Summary
 void close()
          Closes the connection to the remote server.
 void commLinkLost()
          This function is called when the system has detected a communications fault to the server.
 void forwardPacket(Packet packet)
          Called by the ReceiveThread and any internal functions when a packet is to be sent to its required destination.
 void init(BaseComponent parent, Packet initialPacket, int clientType, java.lang.Object configuration)
          This function initialises the connection module and establishes a link to the Amber server.
 void run()
          This function is a one-shot routine which is concerned with establishing a connection to the server.
 void sendPacket(Packet packet)
          Sends a packet to the remote server.
 void setSessionId(java.lang.String sessionId)
          Sets the internal session identifier which is used when the connection is reestablished.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

parent

protected BaseComponent parent

sessionId

protected java.lang.String sessionId

socket

protected java.net.Socket socket

serverName

protected java.lang.String serverName
The address of the Amber Server.

serverPort

protected int serverPort
The port the Amber Server is listening on.

clientType

protected int clientType
Constructor Detail

SocketConnection

public SocketConnection()
Default constructor.
Method Detail

init

public void init(BaseComponent parent,
                 Packet initialPacket,
                 int clientType,
                 java.lang.Object configuration)
          throws java.io.IOException
This function initialises the connection module and establishes a link to the Amber server. At some point in the initialisation the function will call the parent object with the initial session packet. The parent MUST in turn set the session ID before returning.
Specified by:
init in interface ConnectionModule
Parameters:
initialPacket - to send to the server.
clientType - int type of client object connecting.
configuration - Object containing optional configuration information. If this object is null the module will query the parent using getParameter to get the required information.
Throws:
java.io.IOException - with any connection problems.

setSessionId

public void setSessionId(java.lang.String sessionId)
Sets the internal session identifier which is used when the connection is reestablished.
Specified by:
setSessionId in interface ConnectionModule
Parameters:
sessionId - String containing the session identifier.

sendPacket

public void sendPacket(Packet packet)
Sends a packet to the remote server.
Specified by:
sendPacket in interface ConnectionModule
Parameters:
packet - Packet to send to the server.

forwardPacket

public void forwardPacket(Packet packet)
                   throws AmberException
Called by the ReceiveThread and any internal functions when a packet is to be sent to its required destination. This function examines the packet and passes it to the appropriate applet.
Specified by:
forwardPacket in interface ConnectionModule
Parameters:
packet - Packet containing the information to send to the specified component.
Throws:
AmberException - containing any errors.

close

public void close()
Closes the connection to the remote server.
Specified by:
close in interface ConnectionModule

commLinkLost

public void commLinkLost()
This function is called when the system has detected a communications fault to the server. It is the responsibility of the module to reestablish the link to the server.
Specified by:
commLinkLost in interface ConnectionModule

run

public void run()
This function is a one-shot routine which is concerned with establishing a connection to the server. It is initiated when connecting or reconnecting to the server.
Specified by:
run in interface java.lang.Runnable


Copyright © 2002 Clearfield Research Ltd. All Rights Reserved.