com.vodafone360.people.service.transport.tcp
Class ConnectionTester

java.lang.Object
  extended by com.vodafone360.people.service.transport.tcp.ConnectionTester

public class ConnectionTester
extends java.lang.Object


Field Summary
private static int MAX_TEST_RESPONSE_WAIT_TIME_MILLIS
          We wait at least 59 seconds for a response from the server.
private  java.io.DataInputStream mIs
           
private  java.io.OutputStream mOs
           
 
Constructor Summary
ConnectionTester(java.io.InputStream is, java.io.OutputStream os)
           
 
Method Summary
private  byte[] getConnectionTestHessianPayload()
          Returns a byte-array containing the data needed for sending a connection test to the RPG.
private  boolean receiveTestResponse()
          Attempts to read any valid RPG response (even if it is not the requested TCP test response)
 boolean runTest()
          Starts a test by sending a test message to the RPG, which the RPG should reply to.
private  boolean sendTestMessage()
          Attempts to send a TCP test message (type 101) to the RPG.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_TEST_RESPONSE_WAIT_TIME_MILLIS

private static final int MAX_TEST_RESPONSE_WAIT_TIME_MILLIS
We wait at least 59 seconds for a response from the server. After that we return false.

See Also:
Constant Field Values

mIs

private java.io.DataInputStream mIs

mOs

private java.io.OutputStream mOs
Constructor Detail

ConnectionTester

public ConnectionTester(java.io.InputStream is,
                        java.io.OutputStream os)
Method Detail

runTest

public boolean runTest()
Starts a test by sending a test message to the RPG, which the RPG should reply to.

Returns:
True if the test succeeded, false if the RPG did not respond in a correct manner.

sendTestMessage

private boolean sendTestMessage()
Attempts to send a TCP test message (type 101) to the RPG.

Returns:
True if sending happened without any exceptions false otherwise.

receiveTestResponse

private boolean receiveTestResponse()
Attempts to read any valid RPG response (even if it is not the requested TCP test response)

Returns:
True if we were able to receive an RPG response, otherwise false will be returned.

getConnectionTestHessianPayload

private byte[] getConnectionTestHessianPayload()
                                        throws java.io.IOException
Returns a byte-array containing the data needed for sending a connection test to the RPG.

Returns:
A byte array representing the connection test request.
Throws:
java.io.IOException - If there was an exception serializing the hash map to a hessian byte array.


JavaDoc