cdac.medinfo.sdk.hl7282.hl7net.upperlayer

## Class ClientSession

- java.lang.Object
- - java.lang.Thread
  - - cdac.medinfo.sdk.hl7282.hl7net.upperlayer.ClientSession

- All Implemented Interfaces:
    IConnectionListener, IDataNotificationListener, IExceptionReceiver, java.lang.Runnable

      public class ClientSession
      extends java.lang.Thread
      implements IDataNotificationListener, IExceptionReceiver, IConnectionListener

  ClientSession is instantiated when Client is Connected to Server end. ClientSession is the entity that represents Client on Server side.

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class java.lang.Thread

      `java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler`

  - ### Field Summary

    - ### Fields inherited from class java.lang.Thread

      `MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ClientSession()` Initializes a new instance of the ClientSession class.
    `ClientSession(IProcessHandler objIProcessHandler, java.net.Socket socket)` Instantiates ClientSession with specified ProcessHandler and Socket object.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `acceptConnection(boolean acceptConnection)` Accept connection.
    `void` | `addClientStatusListener(IClientStatusListener objIClientStatusListener)` Adds the client status listener.
    `boolean` | `close()` Close.
    `void` | `closeConnection()` This function is automatically invoked when connection is closed by remote end.
    `IHL7BatchFile` | `getBatchFile()` Retrieves HL7BatchFile from ClientSession
    `java.net.InetSocketAddress` | `getClientAddress()` Retrieves the client address of ClientSession.
    `EnumErrorCode` | `getErrorCode()` Retrieves Error Code after receiving Message Coming from Remote end
    `ISubscriptionListener` | `getISubscriptionListener()` Retrieves ISubscriptionListener from ClientSession.
    `Message` | `getMessage()` Retrieves Message from ClientSession
    `MessageFactory` | `getMessageFactory()` Retrieves MessageFactory from ClientSession.
    `java.lang.String` | `getMessageStructure()` Retrieves Enumeration of specified Message Structure.
    `IPublishAgent` | `getPublishAgent()` Retrieves IPublishAgent from ClientSession.
    `ISequenceAgent` | `getSequenceAgent()` Retrieves ISequenceAgent from ClientSession.
    `IServerInteractiveContinuation` | `getServerSideQICAgent()` Retrieves IServerInteractiveContinuation from ClientSession.
    `java.lang.String` | `getTiggerEvent()` Retrieves Enumeration of specified Trigger Event.
    `void` | `initComm()` Initializes the communication and registers with all Agents and Listeners.
    `boolean` | `isConnectionAccepted()` Checks if is connection accepted.
    `void` | `notifyData(IHL7BatchFile objHL7BatchFile)` Invoked when HL7BatchFile is received from Remote end.
    `void` | `notifyData(Message objMessage, EnumErrorCode enumErrorCode)` Invoked when Message is received from Remote end.
    `void` | `onException(java.lang.Exception ex, byte[] buffer)` Invoked when exception occurs.
    `void` | `onException(java.lang.Exception ex, ISegmentSet objISegmentSet)` Invoked when exception is fetched while processing Message.
    `void` | `run()` Executes client session thread.
    `boolean` | `sendBatch(IHL7BatchFile objHL7BatchFile)` Sends specified Batch to Network Agent.
    `boolean` | `sendMessage(Message objHL7Message)` Sends specified Message to Network Agent.
    `void` | `setBatchProcessor(IBatchProcessor objIBatchProcessor)` Sets the Batch Processor
    `void` | `setClientAddress(java.net.InetSocketAddress objClientAddress)` Sets the client address of ClientSession.
    `void` | `setFragmentProcessor(IFragmentProcessor objIFragmentProcessor)` Sets the Fragment Processor
    `void` | `setICanceledQueryReceiver(ICanceledQueryReceiver objCanceledQueryReceiver)` This will set the ICanceledQueryReceiver on Client session.
    `void` | `setInteractiveQueryReciever(IInteractiveQueryReciever objInteractiveQueryReciever)` This will set the Interactive Query Receiver.
    `void` | `setISubscriptionListener(ISubscriptionListener objISubscriptionListener)` Sets instance of ISubscriptionListener on ClientSession.
    `void` | `setMessageFactory(MessageFactory objMessageFactory)` Sets MessageFactory on ClientSession.
    `void` | `setMLLPProcessor(IMLLP objIMLLP)` Sets the MLLP Processor.
    `void` | `setPublishAgent(IPublishAgent objPublishAgent)` Sets instance of PublishAgent on ClientSession.
    `void` | `setReadWriteLength(int iReadLength, int iWriteLength)` Sets max length limit of reading and writing.
    `void` | `setSequenceAgent(ISequenceAgent objSequenceAgent)` Sets the Sequence Agent.
    `void` | `setServerSideQCNAgent(IServerQueryCancellation objServerSideQCNAgent)` This will set the Query Cancellation agent on ClientSideMessageAgent
    `void` | `setServerSideQICAgent(IServerInteractiveContinuation objServerSideQICAgent)` Sets the Interactive Continuation Agent.
    `void` | `setServerSideTransactionHandler(ITransactionHandler objServerSideTransactionHandler)` This will set the ITransactionHandler on Client session.

    - ### 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

      `equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### ClientSession

          public ClientSession()

      Initializes a new instance of the ClientSession class.

    - #### ClientSession

          public ClientSession(IProcessHandler objIProcessHandler,
                       java.net.Socket socket)
                        throws java.io.IOException

      Instantiates ClientSession with specified ProcessHandler and Socket object.
      Parameters:
        `objIProcessHandler` - specified Process Handler
        `socket` - given socket object
      Throws:
        `java.io.IOException`

  - ### Method Detail

    - #### getISubscriptionListener

          public ISubscriptionListener getISubscriptionListener()

      Retrieves ISubscriptionListener from ClientSession.
      Returns:
        ISubscriptionListener - instance of ISubscriptionListener

    - #### setISubscriptionListener

          public void setISubscriptionListener(ISubscriptionListener objISubscriptionListener)

      Sets instance of ISubscriptionListener on ClientSession.
      Parameters:
        `ISubscriptionListener` - - instance of ISubscriptionListener

    - #### getPublishAgent

          public IPublishAgent getPublishAgent()

      Retrieves IPublishAgent from ClientSession.
      Returns:
        IPublishAgent - instance of PublishAgent.

    - #### getServerSideQICAgent

          public IServerInteractiveContinuation getServerSideQICAgent()

      Retrieves IServerInteractiveContinuation from ClientSession.
      Returns:
        IServerInteractiveContinuation - instance of IServerInteractiveContinuation.

    - #### getSequenceAgent

          public ISequenceAgent getSequenceAgent()

      Retrieves ISequenceAgent from ClientSession.
      Returns:
        ISequenceAgent - instance of ISequenceAgent.

    - #### setServerSideQICAgent

          public void setServerSideQICAgent(IServerInteractiveContinuation objServerSideQICAgent)

      Sets the Interactive Continuation Agent.
      Parameters:
        `objServerSideQICAgent` - the ServerSideQICAgent to set.

    - #### setPublishAgent

          public void setPublishAgent(IPublishAgent objPublishAgent)

      Sets instance of PublishAgent on ClientSession.
      Parameters:
        `objPublishAgent` - - instance of PublishAgent.

    - #### setInteractiveQueryReciever

          public void setInteractiveQueryReciever(IInteractiveQueryReciever objInteractiveQueryReciever)

      This will set the Interactive Query Receiver.
      Parameters:
        `objInteractiveQueryReciever` - - implementor of IInteractiveQueryReciever.

    - #### setICanceledQueryReceiver

          public void setICanceledQueryReceiver(ICanceledQueryReceiver objCanceledQueryReceiver)

      This will set the ICanceledQueryReceiver on Client session.
      Parameters:
        `objCanceledQueryReceiver` - - implementor of ICanceledQueryReceiver

    - #### setServerSideTransactionHandler

          public void setServerSideTransactionHandler(ITransactionHandler objServerSideTransactionHandler)

      This will set the ITransactionHandler on Client session.
      Parameters:
        `objServerSideTransactionHandler` - - implementor of ITransactionHandler

    - #### setFragmentProcessor

          public void setFragmentProcessor(IFragmentProcessor objIFragmentProcessor)

      Sets the Fragment Processor
      Parameters:
        `objIFragmentProcessor` - the objIFragmentProcessor to set

    - #### setMLLPProcessor

          public void setMLLPProcessor(IMLLP objIMLLP)

      Sets the MLLP Processor.
      Parameters:
        `objIMLLP` - the MLLP processor to set.

    - #### setSequenceAgent

          public void setSequenceAgent(ISequenceAgent objSequenceAgent)

      Sets the Sequence Agent.
      Parameters:
        `objSequenceAgent` - instance of Sequence Agent.

    - #### setBatchProcessor

          public void setBatchProcessor(IBatchProcessor objIBatchProcessor)

      Sets the Batch Processor
      Parameters:
        `objIBatchProcessor` - the objIBatchProcessor to set

    - #### getErrorCode

          public EnumErrorCode getErrorCode()

      Retrieves Error Code after receiving Message Coming from Remote end
      Returns:
        EnumErrorCode error code

    - #### getMessage

          public Message getMessage()

      Retrieves Message from ClientSession
      Returns:
        Message Message object

    - #### getBatchFile

          public IHL7BatchFile getBatchFile()

      Retrieves HL7BatchFile from ClientSession
      Returns:
        IHL7BatchFile Specifies object of batch file.

    - #### setMessageFactory

          public void setMessageFactory(MessageFactory objMessageFactory)

      Sets MessageFactory on ClientSession.
      Parameters:
        `objMessageFactory` - Specifies object of Message Factory.

    - #### getMessageFactory

          public MessageFactory getMessageFactory()

      Retrieves MessageFactory from ClientSession.
      Returns:
        MessageFactory Specifies object of Message Factory.

    - #### addClientStatusListener

          public void addClientStatusListener(IClientStatusListener objIClientStatusListener)

      Adds the client status listener.
      Parameters:
        `objIClientStatusListener` - Specifies Object of Client Status Listener.

    - #### getClientAddress

          public java.net.InetSocketAddress getClientAddress()

      Retrieves the client address of ClientSession.
      Returns:
        InetSocketAddress The client address

    - #### setClientAddress

          public void setClientAddress(java.net.InetSocketAddress objClientAddress)

      Sets the client address of ClientSession.
      Parameters:
        `objClientAddress` - The new client address

    - #### isConnectionAccepted

          public boolean isConnectionAccepted()

      Checks if is connection accepted.
      Returns:
        boolean true if is connection accepted.

    - #### acceptConnection

          public void acceptConnection(boolean acceptConnection)

      Accept connection.
      Parameters:
        `acceptConnection` - The accept connection

    - #### getMessageStructure

          public java.lang.String getMessageStructure()

      Retrieves Enumeration of specified Message Structure.
      Returns:
        String Enumeration of Message Structure.

    - #### getTiggerEvent

          public java.lang.String getTiggerEvent()

      Retrieves Enumeration of specified Trigger Event.
      Returns:
        String Enumeration of Trigger Event.

    - #### setReadWriteLength

          public void setReadWriteLength(int iReadLength,
                                int iWriteLength)

      Sets max length limit of reading and writing.
      Parameters:
        `iReadLength` - value of Reading max length.
        `iWriteLength` - value of Writing max length.

    - #### onException

          public void onException(java.lang.Exception ex,
                         byte[] buffer)

      Invoked when exception occurs.
      Specified by:
        `onException` in interface `IExceptionReceiver`
      Parameters:
        `ex` - Exception occurred
        `byte[]` - buffer-buffer byte array containing data for which exception is thrown.

    - #### onException

          public void onException(java.lang.Exception ex,
                         ISegmentSet objISegmentSet)

      Invoked when exception is fetched while processing Message.
      Specified by:
        `onException` in interface `IExceptionReceiver`
      Parameters:
        `ex` - Exception fetched.
        `buffer` - data for which error is fetched.

    - #### initComm

          public void initComm()

      Initializes the communication and registers with all Agents and Listeners.

    - #### sendMessage

          public boolean sendMessage(Message objHL7Message)
                              throws java.io.IOException

      Sends specified Message to Network Agent.
      Parameters:
        `objHL7Message` - Specified message to be sent.
      Throws:
        `java.io.IOException`

    - #### sendBatch

          public boolean sendBatch(IHL7BatchFile objHL7BatchFile)
                            throws java.io.IOException

      Sends specified Batch to Network Agent.
      Parameters:
        `objHL7Batch` - Received Batch .
      Throws:
        `java.io.IOException` - Thrown when Message Validation fails.

    - #### run

          public void run()

      Executes client session thread.
      Specified by:
        `run` in interface `java.lang.Runnable`
      Overrides:
        `run` in class `java.lang.Thread`

    - #### notifyData

          public void notifyData(Message objMessage,
                        EnumErrorCode enumErrorCode)
                          throws java.io.IOException

      Invoked when Message is received from Remote end.
      Specified by:
        `notifyData` in interface `IDataNotificationListener`
      Parameters:
        `objMessage` - Received Message
        `enumErrorCode` - Received error code
      Throws:
        `java.io.IOException` - Thrown when IO operation fails.
        `SerializeException` - Thrown when serialization of Message fails.

    - #### notifyData

          public void notifyData(IHL7BatchFile objHL7BatchFile)

      Invoked when HL7BatchFile is received from Remote end.
      Specified by:
        `notifyData` in interface `IDataNotificationListener`
      Parameters:
        `objHL7BatchFile` - Received HL7BatchFile

    - #### closeConnection

          public void closeConnection()

      This function is automatically invoked when connection is closed by remote end.
      Specified by:
        `closeConnection` in interface `IConnectionListener`

    - #### close

          public boolean close()
                        throws java.io.IOException

      Close.
      Returns:
        true, if successful
      Throws:
        `java.io.IOException`

    - #### setServerSideQCNAgent

          public void setServerSideQCNAgent(IServerQueryCancellation objServerSideQCNAgent)

      This will set the Query Cancellation agent on ClientSideMessageAgent
      Parameters:
        `objQCNAgent` - Specifies Object of Server Side Query Cancellation agent.