com.adventnet.tl1
Interface TL1Client

All Known Implementing Classes:
TL1Adaptor.MyTL1Agent, com.adventnet.agent.tl1.TL1Agent

public interface TL1Client

This is an interface that needs to be implemented to receive and process the TL1Message from the TL1Agent. This is mainly used in asynchronous mode of message transfer. The TL1Session invokes the callback(...) method upon succesfully receiving the TL1Message from the TL1Agent.

If the request has been timed out, then callback will be invoked with null message for the corresponding correlation tag of the request sent.
The implementation of this interface should be registered with TL1Session as follows.

 session.addTL1Client(TL1ClientImpl)
 
where session is the instance of TL1Session and TL1ClientImpl is the implementation of this interface.
Click here to view an application program for asynchronous mode of communication which implements this interface.

See Also:
TL1Session.addTL1Client(com.adventnet.tl1.TL1Client), TL1Session.removeTL1Client(com.adventnet.tl1.TL1Client), TL1Session

Method Summary
 void callback(TL1Session session, java.lang.String responseString, java.lang.String tag, byte mesgType)
          This method will be invoked whenever a message is received from the agent and parsing is disabled.
 boolean callback(TL1Session session, TL1Message msg, java.lang.String tag)
          This method will be invoked whenever a TL1Message is received from the agent and parsed successfully.
 void processErrorMessage(TL1Session session, java.lang.String errorMsg)
          This method will be invoked, if the syntax of the message received from the agent is not compliant to TL1 standards.
 

Method Detail

callback

boolean callback(TL1Session session,
                 TL1Message msg,
                 java.lang.String tag)
This method will be invoked whenever a TL1Message is received from the agent and parsed successfully. Here the user may wish to print the message on the console,or save it to a database.

Parameters:
session - TL1Session instance.
msg - TL1Message Received.
tag - This tag is the Correlation Tag of the TL1AckMessage/ TL1ResponseMessage,if the msg is an instanceof TL1AckMessage/ TL1ResponseMessage
This tag is the Correlation Tag of the TL1InputMessage(Request sent), if the msg is null (ie if the request has been timed out).
This tag is the Autonomously Generated Correlation Tag (ATAG), if the msg is an instanceof TL1AutonomousMessage.
Returns:
A boolean value which is used to identify the TL1Message with a particular TL1Client.In the callback(..) method of the TL1Client,which is provided by the API-user,return true,only if the particluar TL1Message is intended to be processed by that TL1Client.If not,return false.

callback

void callback(TL1Session session,
              java.lang.String responseString,
              java.lang.String tag,
              byte mesgType)
This method will be invoked whenever a message is received from the agent and parsing is disabled. Here the application may specify what has to be done with the output message from the TL1 Agent(ie whether to print the message on to the console or save it to a file in a database...etc.)

Parameters:
session - TL1Session instance.
responseString - The raw/unparsed data received in the form of a String.
tag - This tag is the Correlation Tag of the responseString which could be either an acknowledgement/response message. message
This tag is the Autonomously Generated Correlation Tag (ATAG), if the responseString is an autonomous message.
mesgType - Type of message as byte. This byte constant can be any one of the four bytes, viz

TL1API.INPUT_MESSAGE ,
TL1API.ACK_MESSAGE ,
TL1API.RESPONSE_MESSAGE and
TL1API.AUTONOMOUS_MESSAGE.
If it is an invalid message this byte constant value is -1.


processErrorMessage

void processErrorMessage(TL1Session session,
                         java.lang.String errorMsg)
This method will be invoked, if the syntax of the message received from the agent is not compliant to TL1 standards.

Parameters:
session - TL1Session instance.
errorMsg - Error String.