com.adventnet.tl1
Class TL1Session

java.lang.Object
  extended by java.lang.Thread
      extended by com.adventnet.tl1.TL1Session
All Implemented Interfaces:
java.io.Serializable, java.lang.Runnable

public class TL1Session
extends java.lang.Thread
implements java.io.Serializable

Instantiate TL1Session to send or receive TL1 messages from any TL1 peer. This class has to be instantiated,for any communication to take place between the Manager application and the TL1Agent.

After creating a TL1API instance and invoking start(),instantiate TL1Session by providing the TL1API instance as an argument to the constructor and use the method open(targetHost,targetPort) or open() to create the Socket for communication.

After successful creation of TL1Session , you may use the method send(TL1Message) or syncSend(TL1Message) in order to send messages to the TL1Agent.

See Also:
TL1Message, TL1InputMessage, TL1ResponseMessage, TL1AckMessage, TL1AutonomousMessage, Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
(package private)  java.lang.String ack
           
(package private)  TL1API api
           
(package private)  java.io.RandomAccessFile binFile
           
(package private)  TL1TextBlock block
           
(package private)  ConnectionHandler connectionHandler
           
(package private)  ConnectionListener connectionListener
           
(package private)  boolean connectStatus
           
(package private)  boolean isAutonomousMsgRcvd
           
(package private)  TL1KeepAlive keepAlive
           
(package private)  java.io.RandomAccessFile logfile
           
(package private)  boolean loopFlag
           
(package private)  MessageFormatter messageFormatter
           
(package private)  java.lang.Thread monThread
           
(package private)  TL1Parser parser
           
(package private)  TL1ParserOptions parserOptions
           
(package private)  com.adventnet.tl1.transport.ProtocolOptions protocolOptions
           
(package private)  java.lang.String recdMsgHolder
          contains the received messages
(package private)  java.lang.Object sessionClassifier
           
(package private)  boolean syncSendInProgress
           
(package private)  java.lang.String textBlock
           
(package private)  java.util.Vector timeouts
           
(package private)  com.adventnet.tl1.transport.TL1TransportProvider transportProvider
           
(package private)  java.lang.Class transportProviderClass
           
(package private)  java.lang.String transportProviderClassName
           
(package private)  java.lang.String transportProviderFileName
           
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
TL1Session()
          Default Constructor.
TL1Session(TL1API api)
          Creates a new TL1Session object by taking the TL1API instance.
TL1Session(TL1API api, java.net.Socket sock)
          Creates a new TL1Session object by taking the TL1API instance and the reference to the Socket.
TL1Session(TL1API api, TL1Parser parser)
          Creates a new TL1Session object by taking the TL1API instance and TL1Parser instance.
TL1Session(TL1API api, TL1Parser parser, java.net.Socket sock)
          Creates a new TL1Session object by taking the TL1API instance, TL1Parser and the Socket instance.
 
Method Summary
 void addTL1Client(TL1Client client)
          This method is provided to subscribe for callbacks.
 java.lang.String[] checkResponses()
          Checks for any outstanding responses that are still in the receive queue.
 boolean checkTimeout(java.lang.String Ctag)
          Returns true if the request-ID given in the form of a C-Tag,is in the list of this session's timed out requests,and removes it from the list.
 void close()
          Stops the thread and closes the socket.
 void enableTransportProvider(boolean flag)
          If protocol other than default TCP is to be used, then this method should be used to set this flag to true.
 ConnectionHandler getConnectionHandler()
          To get a reference to the ConnectionHandler object.
 ConnectionListener getConnectionListener()
          To get reference to the ConnectionListener object.
 java.lang.String getLocalHost()
          Get the local TL1 entity name or dotted IP address of TL1 entity.
 int getLocalPort()
          Get the local TCP port on the peer that this session is used to communicate with.
 TL1Parser getParser()
          This method returns the reference to the TL1Parser.
 com.adventnet.tl1.transport.ProtocolOptions getProtocolOptions()
          This method will return the ProtocolOptions associated with this TL1Session.
 int getRetries()
          Get number of retries before timeout.
(package private)  TL1Session getSession()
          Returns the current TL1Session instance.
 java.lang.Object getSessionClassifier()
          This method is used to get the Object value of session classifier set using setSessionClassifier(..) of this class.
 java.lang.String getTargetHost()
          To get remote TL1 entity name or dotted IP address of TL1 entity.
 int getTargetPort()
          Get the remote TCP port on the peer that this session is used to communicate with.
 TASClient getTASClient()
          This method is internally called by our API's.
 int getTimeout()
          To get the timeout value.
 TL1ParserOptions getTL1ParserOptions()
          This method returns TL1ParserOptions for the user to set the options related to the parser.
 com.adventnet.tl1.transport.TL1TransportProvider getTransportProvider()
          This method will return the TL1TransportProvider object associated with this TL1Session.
 java.lang.String getTransportProviderClassName()
          To get the Transport Provider Class name.
(package private)  void initTransportProvider()
           
 boolean isConnected()
          To check the status of the session.
 boolean isIgnoreAutoMsg()
          To check whether the session is ignoring the Autonomous message or not.
 boolean isSetPartialMesgAccumulation()
          To get the mode of processing the partial messages.
 boolean isSetTransportProvider()
          This method returns true if protocol used is other than the default protocol,which is TCP.
 void keepAlive(TL1Message tl1message, int freq)
          To maintain the connection with the device, when no message is being sent by the user for a long time.
(package private)  void monitorRequests()
          Monitors user requests for timeouts
 void open()
           
 void open(java.applet.Applet applet)
          Opens TL1 Session to communicate with the TL1 peer through an Applet instance.
 void open(java.util.Hashtable params)
          Opens TL1Session to communicate with a TL1 peer.
 void open(java.lang.String remoteHost, int remotePort)
          Opens TL1Session to communicate with the TL1 peer.
 void open(java.lang.String remoteHost, int remotePort, java.applet.Applet applet)
          Opens TL1Session to communicate with the TL1 peer through an Applet instance.
(package private)  void receive()
          receiver method which waits for incoming TL1Messages.
 TL1Message receive(java.lang.String ctag)
          To receive the response received for a particular ctag value.
 void removeConnectionHandler()
          Unsubscribe for ConnectionHandler.
 void removeConnectionListener()
          Unsubscribe for ConnectionListener.
 void removeMessageFormatter()
          This removes your MessageFormatter interface implementation from this session
 boolean removeTL1Client(TL1Client client)
          This method is used to unsubscribe for callbacks.
 void run()
          The run() method starts the receiver thread for the session.
 void send(byte[] toSend)
          This method enables the application to send the TL1 message(raw/unparsed) on the given session, if message parsing is disabled.
 void send(TL1Message msg)
          Send the TL1Message through the given session after encoding the message.
 void setAppletLogFile(java.io.DataOutputStream dos)
          To Set the DataOutputStream with the given value.
 void setConnectionHandler(ConnectionHandler connHandler)
          Subscribe for ConnectionHandler implementation.
 void setConnectionListener(ConnectionListener connListener)
          To subscribe for ConnectionListener implementation.
 void setIgnoreAutoMsg(boolean flag)
          To set the flag for ignoring the Autonomous message.
 void setLog(boolean log)
          To set the debugging mode with the given boolean value.
 void setMessageFormatter(MessageFormatter mesgFormatter)
          Set the implementation of the interface MessageFormatter.
 void setParser(TL1Parser par)
          To set the parser instance to be used for parsing the messages received.
 void setPartialMesgAccumulation(boolean flag)
          This method is used to specify how the message is to be handled, if the message is recieved in parts(that is the whole message is not received at the same time,but rather the message is received only in several pieces before the terminating semi-colon is received).
 void setProtocolOptions(com.adventnet.tl1.transport.ProtocolOptions tParam)
          This associates the ProtocolOptions object with this TL1Session.
 void setRetries(int retries)
          Set the number of retries before timeout.
 void setSessionClassifier(java.lang.Object obj)
          This method is used for storing some application specific details.
 void setTimeout(int timeout)
          Set the timeout value.
 void setTransportProvider(com.adventnet.tl1.transport.TL1TransportProvider provider)
          To set the TL1TransportProvider implementation with the given value.
 void setTransportProviderClassName(java.lang.String className)
          To set the Transport Provider Class name.
 void stopKeepAlive()
          To stop the keep alive thread.
 TL1Message syncSend(TL1Message msg)
          This method is used to send the TL1Message synchronously.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

api

TL1API api

connectionHandler

ConnectionHandler connectionHandler

connectionListener

ConnectionListener connectionListener

messageFormatter

MessageFormatter messageFormatter

logfile

java.io.RandomAccessFile logfile

binFile

java.io.RandomAccessFile binFile

transportProvider

com.adventnet.tl1.transport.TL1TransportProvider transportProvider

transportProviderFileName

java.lang.String transportProviderFileName

protocolOptions

com.adventnet.tl1.transport.ProtocolOptions protocolOptions

transportProviderClass

java.lang.Class transportProviderClass

transportProviderClassName

java.lang.String transportProviderClassName

loopFlag

boolean loopFlag

recdMsgHolder

java.lang.String recdMsgHolder
contains the received messages


parser

TL1Parser parser

keepAlive

TL1KeepAlive keepAlive

connectStatus

boolean connectStatus

parserOptions

TL1ParserOptions parserOptions

sessionClassifier

java.lang.Object sessionClassifier

ack

java.lang.String ack

textBlock

java.lang.String textBlock

block

TL1TextBlock block

monThread

java.lang.Thread monThread

isAutonomousMsgRcvd

boolean isAutonomousMsgRcvd

syncSendInProgress

boolean syncSendInProgress

timeouts

java.util.Vector timeouts
Constructor Detail

TL1Session

TL1Session()
Default Constructor. This is not used presently.


TL1Session

public TL1Session(TL1API api)
Creates a new TL1Session object by taking the TL1API instance. The TL1API instance is required so that this session registers with the TL1API and the TL1API can start monitoring the sessions for timeouts.A single instance of TL1API can monitor several TL1Session objects.

Parameters:
api - The instance of TL1API
See Also:
TL1API

TL1Session

public TL1Session(TL1API api,
                  TL1Parser parser)
Creates a new TL1Session object by taking the TL1API instance and TL1Parser instance. The TL1API instance is required so that this session registers with the TL1API and the TL1API can start monitoring the sessions for timeouts.

Parameters:
api - The instance of TL1API
parser - TL1Parser instance.
See Also:
TL1Parser

TL1Session

public TL1Session(TL1API api,
                  java.net.Socket sock)
           throws java.lang.Exception
Creates a new TL1Session object by taking the TL1API instance and the reference to the Socket. The TL1API instance is required so that this session registers with the TL1API and the TL1API can start monitoring the sessions for timeouts.

Parameters:
api - The instance of TL1API
sock - The instance of Socket.
Throws:
java.lang.Exception

TL1Session

public TL1Session(TL1API api,
                  TL1Parser parser,
                  java.net.Socket sock)
           throws java.lang.Exception
Creates a new TL1Session object by taking the TL1API instance, TL1Parser and the Socket instance. The TL1API instance is required so that this session registers with the TL1API and the TL1API can start monitoring the sessions for timeouts.

Parameters:
api - The instance of TL1API
parser - TL1Parser instance.
sock - Instance of Socket.
Throws:
java.lang.Exception
See Also:
TL1API, TL1Parser
Method Detail

setAppletLogFile

public void setAppletLogFile(java.io.DataOutputStream dos)
To Set the DataOutputStream with the given value. The log message will be written on to this OutputStream.

Parameters:
dos - DataOutputStream

setLog

public void setLog(boolean log)
To set the debugging mode with the given boolean value. Used for debugging.If the parameter passed is true then log files will be created for the entire TL1Session,or else no log file will be created.These log files can be found in the same directory from which the Application program is run.There will be two log files named "bin.txt" and "sessionlog.txt",which may be used for debugging analysis.

Parameters:
log - boolean value.

setPartialMesgAccumulation

public void setPartialMesgAccumulation(boolean flag)
This method is used to specify how the message is to be handled, if the message is recieved in parts(that is the whole message is not received at the same time,but rather the message is received only in several pieces before the terminating semi-colon is received). This happens when the Textblock of the response message is very big. In this case,the message will be broken into several chunks,and hence will not be passed as a single unit. If the 'flag' is set to false, it will cause the application to receive partial messages as and when the chunks of the same message arrive. Otherwise if the flag is true,the TL1Session will accumulate all the partial messages till it receives the complete message with the terminator character,that is,the semicolon (";").

Parameters:
flag - true if partial message is to be accumulated till the end of the message,else false which means that the partial messages will be sent to the application immediately,without waiting for the end of the message.

isSetPartialMesgAccumulation

public boolean isSetPartialMesgAccumulation()
To get the mode of processing the partial messages. (that is to determine whether or not,the partial messages are being accumulated by the TL1Session,till the terminator character of the message is received,or to pass on the pieces of the output message to the application,as and when the different pieces of the same message arrive.)

True - Partial messages get accumulated till the terminating character, that is,the semicolon is received,otherwise false. By default this flag will be true.

Returns:
true if partial messages are accumulated till the end of the message(the terminator semicolon ";") is reached, otherwise false.

getTL1ParserOptions

public TL1ParserOptions getTL1ParserOptions()
This method returns TL1ParserOptions for the user to set the options related to the parser. There are several options availabe to customise the parsing of the TL1Messages.Options to turn on,or turn off the parsing of the entire TL1Message as well as the option to turn off the parsing of the Textblock alone,are available in the TL1ParserOptions class.The other avaliable options in the returned object are to enable the TL1Session to drop TL1AckMessages and TL1AutonomousMessages according to the preference of the user. There is also an option to drop the echo of the TL1InputMessage (Some TL1 Agents echo the input message)

Returns:
Returns TL1ParserOptions.
See Also:
TL1ParserOptions

getSession

TL1Session getSession()
Returns the current TL1Session instance.

Returns:
reference to this instance of TL1Session.

addTL1Client

public void addTL1Client(TL1Client client)
This method is provided to subscribe for callbacks. This adds your TL1Client interface implementation to this session, which will invoke your class's callback(...) function. The TL1Client interface is implemented by applications that wish to send and receive messages asynchronously.The TL1Client interface provides a callback(...) method that avoids polling done to check for responses. The callback(...)methods of all the applications that implement TL1Client interface,and also register with a particular TL1Session using this method,will be called automatically by the TL1Session,when a response arrives.

Parameters:
client - TL1Client instance.
See Also:
TL1Client

removeTL1Client

public boolean removeTL1Client(TL1Client client)
This method is used to unsubscribe for callbacks. This removes your TL1Client interface implementation from this session's list of registered TL1Client implementations. Once this method is invoked,the TL1Session will stop informing the TL1Client implementation(passed as argument to this method),when messages are received.However,the other TL1Clients registered with the TL1Session,will continue to receive the messages,passed on by the TL1Session.

Parameters:
client - TL1Client instance.
Returns:
True if the TL1Client implementation was removed succesfully, else False.
See Also:
TL1Client

setMessageFormatter

public void setMessageFormatter(MessageFormatter mesgFormatter)
Set the implementation of the interface MessageFormatter. This adds your MessageFormatter interface implementation to this session,which will invoke your formatMessageToSend(...) and formatMessageReceived(...) functions. Registering this implementation should have to be done after opening the session.
In case of syncSend, if formatMessageReceived returns null, the message to be sent is dropped, and syncSend will timeout.

Parameters:
mesgFormatter - MessageFormatter instance.
See Also:
MessageFormatter

removeMessageFormatter

public void removeMessageFormatter()
This removes your MessageFormatter interface implementation from this session

See Also:
MessageFormatter

setConnectionHandler

public void setConnectionHandler(ConnectionHandler connHandler)
Subscribe for ConnectionHandler implementation. This adds your ConnectionHandler interface implementation to this session,which will invoke your preConnect() and postConnect() functions. Registering this handler should have to be done before opening the session.

Parameters:
connHandler - ConnectionHandler instance.
See Also:
ConnectionHandler

removeConnectionHandler

public void removeConnectionHandler()
Unsubscribe for ConnectionHandler. This removes your ConnectionHandler interface implementation from this session.


getConnectionHandler

public ConnectionHandler getConnectionHandler()
To get a reference to the ConnectionHandler object.

Returns:
ConnectionHandler object.
See Also:
ConnectionHandler

setConnectionListener

public void setConnectionListener(ConnectionListener connListener)
To subscribe for ConnectionListener implementation. This adds your ConnectionListener interface implementation to this session,which will invoke your processConnectionDown() function. These two methods will enable you to specify the necessary action to be taken,when the connection between the manager and the device,goes down or is restored.

Parameters:
connListener - ConnectionListener instance.
See Also:
ConnectionListener

removeConnectionListener

public void removeConnectionListener()
Unsubscribe for ConnectionListener. This removes your ConnectionListener interface implementation from this session.

See Also:
ConnectionListener

getConnectionListener

public ConnectionListener getConnectionListener()
To get reference to the ConnectionListener object.

Returns:
ConnectionListener object.
See Also:
ConnectionListener

getTargetHost

public java.lang.String getTargetHost()
To get remote TL1 entity name or dotted IP address of TL1 entity. This method can be called after creation of TCPsocket.

Returns:
The domain name or the dotted IP address of the peer.

getTargetPort

public int getTargetPort()
Get the remote TCP port on the peer that this session is used to communicate with.

Returns:
The remote port on the peer that this session is used to communicate.

getLocalHost

public java.lang.String getLocalHost()
Get the local TL1 entity name or dotted IP address of TL1 entity. This method can be called after creation of TCPSocket.

Returns:
The local name or the dotted IP address of the peer.

getLocalPort

public int getLocalPort()
Get the local TCP port on the peer that this session is used to communicate with. This method is just there for providing information as to which port is being used locally.This port cannot be set by the user.In the real situation,this port is dynamically assigned by the run-time environment.

Returns:
The local port on the peer that this session is used to communicate.

getTASClient

public TASClient getTASClient()
This method is internally called by our API's. So this method should not be invoked by the user. To get the reference to the TASClient instance.

Returns:
Returns the TASClient instance.

initTransportProvider

void initTransportProvider()
                     throws java.lang.Exception
Throws:
java.lang.Exception

setProtocolOptions

public void setProtocolOptions(com.adventnet.tl1.transport.ProtocolOptions tParam)
This associates the ProtocolOptions object with this TL1Session. The ProtocolOptions is a class,that is used by applications that wish to plug-in their own,default communication protocol,instead of the default TCP.

Parameters:
tParam - ProtocolOptions to be set.
See Also:
ProtocolOptions

getProtocolOptions

public com.adventnet.tl1.transport.ProtocolOptions getProtocolOptions()
This method will return the ProtocolOptions associated with this TL1Session. This object will be null,if the default transportation mechanism (ie TCP) is used by the user.

Returns:
The ProtocolOptions corresponding to this TL1Session.

enableTransportProvider

public void enableTransportProvider(boolean flag)
If protocol other than default TCP is to be used, then this method should be used to set this flag to true. If this flag is false,then the default protocol,ie TCP will be used for communication.

Parameters:
flag - if the flag is false than the default protocol TCP is used.

isSetTransportProvider

public boolean isSetTransportProvider()
This method returns true if protocol used is other than the default protocol,which is TCP.

Returns:
true if protocol provider is used.

getTransportProvider

public com.adventnet.tl1.transport.TL1TransportProvider getTransportProvider()
This method will return the TL1TransportProvider object associated with this TL1Session. This object will be null,if the application uses the default protocol,that is TCP.

Returns:
Object instance of TL1TransportProvider.

setTransportProvider

public void setTransportProvider(com.adventnet.tl1.transport.TL1TransportProvider provider)
To set the TL1TransportProvider implementation with the given value.

Parameters:
provider - TL1TransportProvider implementation to set.

setTransportProviderClassName

public void setTransportProviderClassName(java.lang.String className)
                                   throws java.lang.Exception
To set the Transport Provider Class name. This class will be searched for in the classpath and will be used for the TL1 communication with the remote device.

Parameters:
className - The provider classname
Throws:
java.lang.Exception - if the given class name is not available in the classpath.

getTransportProviderClassName

public java.lang.String getTransportProviderClassName()
To get the Transport Provider Class name.

Returns:
the classname of the TL1TransportProvider in the form of a String.

setSessionClassifier

public void setSessionClassifier(java.lang.Object obj)
This method is used for storing some application specific details. This value is not used by the APIs and the user can get the classifier value set in the session from the callback implementation(TL1Client) using getSessionClassifier() defined in this class.

Parameters:
obj - Object instance.

getSessionClassifier

public java.lang.Object getSessionClassifier()
This method is used to get the Object value of session classifier set using setSessionClassifier(..) of this class.

Returns:
Returns an Object instance.

open

public void open()
          throws java.lang.Exception
Throws:
java.lang.Exception

open

public void open(java.util.Hashtable params)
          throws java.lang.Exception
Opens TL1Session to communicate with a TL1 peer. Once the TL1Session is instantiated,it has to be opened with this method so that a TCP socket is opened for TL1 communication between the manager application and the TL1Agent.

Parameters:
params - Hashtable containing keys and value pairs that are used for opening the session.
Throws:
java.lang.Exception - for remote Host unknown and socket error.

open

public void open(java.applet.Applet applet)
          throws java.lang.Exception
Opens TL1 Session to communicate with the TL1 peer through an Applet instance. Once the TL1Session is instantiated,it has to be opened with this method so that a TCP socket is opened for TL1 communication.The API provides the mechanism to override the restrictions imposed on the applet,by the Java runtime environment.

Parameters:
applet - Applet instance.
Throws:
java.lang.Exception - for target Host unknown and socket error.

open

public void open(java.lang.String remoteHost,
                 int remotePort)
          throws java.lang.Exception
Opens TL1Session to communicate with the TL1 peer. Once the TL1Session is instantiated, it has to be opened with this method so that a TCP socket is opened for TL1 communication. This method also starts the receiver threads, which wait for the incoming TL1Messages.

Parameters:
remoteHost - remote peer name
remotePort - port number
Throws:
java.lang.Exception - for remote Host unknown and Socket error.

open

public void open(java.lang.String remoteHost,
                 int remotePort,
                 java.applet.Applet applet)
          throws java.lang.Exception
Opens TL1Session to communicate with the TL1 peer through an Applet instance. Once the TL1Session is instantiated, it has to be opened with this method so that a TCP socket is opened for TL1 communication.

Parameters:
remoteHost - host name as a string instance.
remotePort - port number as an integer.
applet - Applet instance.
Throws:
java.lang.Exception - for remoteHost unknown and socket error.

keepAlive

public void keepAlive(TL1Message tl1message,
                      int freq)
               throws java.lang.Exception
To maintain the connection with the device, when no message is being sent by the user for a long time. If there is no interaction between the device for a long period the device automatically closes the connection.To avoid such circumstances, the application should start the KeepAlive with the specified time interval.

Parameters:
tl1message - TL1Message to be send to the device after particular interval.
freq - Time interval in seconds.
Throws:
java.lang.Exception - if some unexpected error occurs while keepAlive(..) is in progress.

stopKeepAlive

public void stopKeepAlive()
To stop the keep alive thread.


run

public void run()
The run() method starts the receiver thread for the session. This thread waits for incoming TL1Messages, and updates the TL1Session object with received messages.This method is called from the open()method which opens a socket for TL1 communications. The API user need not call this method explicitly.This method will be called internally.

Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread

receive

void receive()
       throws java.lang.Exception
receiver method which waits for incoming TL1Messages.

Throws:
java.lang.Exception

setParser

public void setParser(TL1Parser par)
To set the parser instance to be used for parsing the messages received. Users may write their own parser classes and set it here to be used for doing parsing. But that parser class must implement TL1Parser interface in order that it may be compatible with this API.

Parameters:
par - TL1Parser instance.
See Also:
TL1Parser

getParser

public TL1Parser getParser()
This method returns the reference to the TL1Parser. User should use this parser for creating TL1 Messages.

Returns:
Returns TL1Parser handle for creating TL1 Messages.

checkResponses

public java.lang.String[] checkResponses()
Checks for any outstanding responses that are still in the receive queue.
If TL1Client has been registered than responses will be sent to the callback and dequed from the receive queue.

Returns:
Returns a string array of ctag's of all the responses in the receive queue.

receive

public TL1Message receive(java.lang.String ctag)
                   throws java.lang.Exception
To receive the response received for a particular ctag value. User can get the ctag values of all responses in the receive queue using the method checkResponses(..) defined in this class.

Parameters:
ctag - CTag value of the response message.
Returns:
Returns TL1Message.
Throws:
java.lang.Exception
See Also:
TL1Message, checkResponses()

send

public void send(TL1Message msg)
          throws java.lang.Exception
Send the TL1Message through the given session after encoding the message. This is an asynchronous request,and hence,this method, returns after transmission. Throws Exception if some error occurs while decoding,or if the host is unknown or if any error occurs while sending the message.

Parameters:
msg - The instance of TL1Message to be sent
Throws:
java.lang.Exception - is thrown on send error.
See Also:
TL1Message

send

public void send(byte[] toSend)
          throws TL1ParserException,
                 java.lang.Exception
This method enables the application to send the TL1 message(raw/unparsed) on the given session, if message parsing is disabled.
If the parser status is false, ie.
session.getTL1ParserOptions().setTL1MessageParsing(false)
the TL1 message (raw/unparsed) will be sent to the agent.
If the parser status is true, internally the byte array of the message will be parsed and sent to the TL1 Agent.
Throws Exception if any error occurs while writing the message to the output stream,or while sending. Throws parser exception if the parser encounters any error while parsing the message.

Parameters:
toSend - The byte array to be sent.
Throws:
TL1ParserException - is thrown, if the syntax of the message is not compliant to TL1 standards.
java.lang.Exception - is thrown on send error.

setIgnoreAutoMsg

public void setIgnoreAutoMsg(boolean flag)
To set the flag for ignoring the Autonomous message. If this flag is set,then the session will ignore all autonomous messages that are recieved and only response messages will be passed on to the application. If the flag is set (true) - then session will wait only for response.

Parameters:
flag - boolean value.

isIgnoreAutoMsg

public boolean isIgnoreAutoMsg()
To check whether the session is ignoring the Autonomous message or not.

Returns:
true if ignoreAutonomousMessage flag is set ,otherwise false.

syncSend

public TL1Message syncSend(TL1Message msg)
                    throws java.lang.Exception
This method is used to send the TL1Message synchronously. This method returns the TL1ResponseMessage and throws Exception if it encounters any error,while this method is in progress. This is a synchronous request, returns after receiving the response.

Parameters:
msg - The TL1Message
Returns:
The response Message.
Throws:
java.lang.Exception - is thrown on send error.
See Also:
TL1Message

isConnected

public boolean isConnected()
To check the status of the session. That is to check if connection exists or not.

Returns:
boolean value true if connection exists and false if not.

close

public void close()
           throws java.lang.Exception
Stops the thread and closes the socket.

Throws:
java.lang.Exception - occurs on failure.

getRetries

public int getRetries()
Get number of retries before timeout. The default number of retries is 0.

Returns:
The retries value being used by the session.

setRetries

public void setRetries(int retries)
Set the number of retries before timeout. The default number of retries is 0.

Parameters:
retries - The retries value to be used by the session.

getTimeout

public int getTimeout()
To get the timeout value. The timeout is the time to wait for the first response in milli-seconds before attempting a retransmission.The default value of timeout is 5000 milliseconds.

Returns:
The timeout value in milliseconds used for monitoring the request

setTimeout

public void setTimeout(int timeout)
Set the timeout value. The default value of timeout is 5000 milliseconds. The timeout value to be set should be in milliseconds. The timeout in the TL1InputMessage overrides the timeout value in session.
Note : User's application timeout should be greater than the timeout value set in TL1Session.

Parameters:
timeout - The timeout value to be used for monitoring the request
See Also:
TL1InputMessage.setTimeout(int), TL1InputMessage

monitorRequests

void monitorRequests()
Monitors user requests for timeouts


checkTimeout

public boolean checkTimeout(java.lang.String Ctag)
Returns true if the request-ID given in the form of a C-Tag,is in the list of this session's timed out requests,and removes it from the list. Returns false if this request-ID is not in the list.

Parameters:
Ctag - The string which acts as the request-ID.
Returns:
true if the message corresponding to the particular Ctag value timed out,else false.