"WEBNMS_5 API Docs"

com.adventnet.management.mstransport
Class MainSocketClient

java.lang.Object
  extended by com.adventnet.management.mstransport.MainSocketClient
All Implemented Interfaces:
java.lang.Runnable

public class MainSocketClient
extends java.lang.Object
implements java.lang.Runnable

This is the basic endpoint for the Management Client.This class handles all the communication done between the Management Client and Server. All the responses from the Management Server are received and processed here. The actual transport of the data (ie., the underlying protocol) is taken care by the TransportProvider implementation class.

See Also:
SocketConnection,TransportProvider

Field Summary
 boolean connected
          The value specifies if the client is connected to the server or not.
 
Constructor Summary
MainSocketClient(java.applet.Applet app)
          Creates a MainSocketClient with the applet argument.The TransportProvider implementation class is retrieved from the CLIENT_CLASS_NAME applet parameter.
MainSocketClient(java.applet.Applet app, java.lang.String className)
          Creates the MainSocketClient with the applet and the TransportProvider Class.
MainSocketClient(java.lang.String hostname, java.lang.String rmi)
          RMI
 
Method Summary
 java.lang.String[] checkResponses()
          Checks for any outstanding responses that are still in the receive queue.
 boolean checkTimeout(java.lang.String reqid)
          Checks whether there are any timed-out requests for this specific ID.
 java.lang.String genReqID()
          Generate a request ID for PDU.
 long getTimeOutCount()
          This method returns the current timeout interval set for synchrous call to the server.
 void killMeSilently()
          Terminates the connection maintained with the server and closes all the resources used up.
 void processMsPDU(byte[] pduData)
          Processes the data received from the transport provider.If the pduData passed is null, this method just returns without performing any operation.
 void registerForMcResponses(com.adventnet.management.mstransport.MsClientListener ms)
           
 void run()
          Implementation of the Runnable interface.
 boolean send(byte[] data)
          This method sends the data asynchronously to the Server.ie., this method returns immediately after placing the request in a request queue.
 void setTimeOutCount(long milliSeconds)
          This method sets the timeOutCount for Synchronized send to the Server.
 byte[] syncSend(java.lang.String id, byte[] data)
          Sends the data to the server and returns only after a response is received for this particular request.ie., the data is transferred synchronously.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

connected

public boolean connected
The value specifies if the client is connected to the server or not.

Constructor Detail

MainSocketClient

public MainSocketClient(java.applet.Applet app)
                 throws com.adventnet.management.transport.TransportException
Creates a MainSocketClient with the applet argument.The TransportProvider implementation class is retrieved from the CLIENT_CLASS_NAME applet parameter.

Parameters:
app - the Web NMS Client Applet.
Throws:
com.adventnet.management.transport.TransportException

MainSocketClient

public MainSocketClient(java.applet.Applet app,
                        java.lang.String className)
                 throws com.adventnet.management.transport.TransportException
Creates the MainSocketClient with the applet and the TransportProvider Class.

Parameters:
app - the Web NMS Client applet.
className - an implementation of the TransportProvider interface
Throws:
com.adventnet.management.transport.TransportException

MainSocketClient

public MainSocketClient(java.lang.String hostname,
                        java.lang.String rmi)
                 throws java.lang.Exception
RMI

Throws:
java.lang.Exception
Method Detail

run

public void run()
Implementation of the Runnable interface. This is basically the receive thread of this MainSocketClient.

Specified by:
run in interface java.lang.Runnable

registerForMcResponses

public void registerForMcResponses(com.adventnet.management.mstransport.MsClientListener ms)

processMsPDU

public void processMsPDU(byte[] pduData)
Processes the data received from the transport provider.If the pduData passed is null, this method just returns without performing any operation.

Parameters:
pduData - the data to be processed

send

public boolean send(byte[] data)
This method sends the data asynchronously to the Server.ie., this method returns immediately after placing the request in a request queue. The data passed to this method will be later processed via scheduling mechanism.

Parameters:
id - the registered id.
data - the data to be sent to the server.
Returns:
true if the send succeeds, false otherwise.

syncSend

public byte[] syncSend(java.lang.String id,
                       byte[] data)
Sends the data to the server and returns only after a response is received for this particular request.ie., the data is transferred synchronously.

Parameters:
id - the registered ID.
data - the data that needs to be sent.
Returns:
byte[] data - the response data or null if there is any time out.

checkTimeout

public boolean checkTimeout(java.lang.String reqid)
Checks whether there are any timed-out requests for this specific ID. If there are any such requests then they are removed from the request queue.

Parameters:
reqid - the request ID for which the time out request is to be verified.
Returns:
true if there are any timed out requests, false otherwise.

checkResponses

public java.lang.String[] checkResponses()
Checks for any outstanding responses that are still in the receive queue. Returns list of requests, i.e. request ids.


genReqID

public java.lang.String genReqID()
Generate a request ID for PDU. Uses the random number generator.

Returns:
the random ID generated.

killMeSilently

public void killMeSilently()
Terminates the connection maintained with the server and closes all the resources used up.


setTimeOutCount

public void setTimeOutCount(long milliSeconds)
This method sets the timeOutCount for Synchronized send to the Server. The time given should be in milliseconds

Parameters:
milliSeconds - The timeOutCount to be set.

getTimeOutCount

public long getTimeOutCount()
This method returns the current timeout interval set for synchrous call to the server.

Returns:
Returns a long value, which will be the current time out interval in milliseconds.

"WEBNMS_5 API Docs"

Copyright © 2011 ZOHO Corp., All Rights Reserved.