com.interfaceware.chameleon
Class LlpConnection

java.lang.Object
  extended by com.interfaceware.chameleon.LlpConnection

public class LlpConnection
extends java.lang.Object

This object is passed as an argument for many of the events of the LlpServer object.

This class provides methods to interact with each discrete client connection.

See http://www.interfaceware.com/manual/network_components.html for more information.


Constructor Summary
LlpConnection()
           
LlpConnection(long Handle)
           
 
Method Summary
 void disconnect()
          Attempt to gracefully disconnect from the server.
protected  void finalize()
           
 int getId()
          A unique ID for all connection objects.
 java.lang.String getRemoteHostName()
           This property will resolve the remoteIpAddress to the host name if possible using the operating system.
 int getRemoteIpAddress()
          The IP address of the remote host in host byte order.
 java.lang.String getRemoteIpAddressAsString()
          The IP address of the remote host as a string.
 void hardDisconnect()
          Ungracefully disconnect without doing TCP/IP handshaking with the server.
 void release()
           
 void transmitMessage(java.lang.String Message)
          Send a message to the client, prefixed and postfixed by the current HeaderBlock and TrailerBlock characters.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LlpConnection

public LlpConnection()
              throws ChameleonException
Throws:
ChameleonException

LlpConnection

public LlpConnection(long Handle)
              throws ChameleonException
Throws:
ChameleonException
Method Detail

release

public void release()
             throws ChameleonException
Throws:
ChameleonException

finalize

protected void finalize()
                 throws ChameleonException
Overrides:
finalize in class java.lang.Object
Throws:
ChameleonException

getRemoteHostName

public java.lang.String getRemoteHostName()
                                   throws ChameleonException

This property will resolve the remoteIpAddress to the host name if possible using the operating system. Sometimes no host name resolution will be possible at which point this function will return 'unknown'.

For the first time this method is called, it blocks until the name is resolved. This means that if you make the call in the context of your message loop your application will appear to freeze for a few seconds.

Subsequent calls will return immediately with a cached value.

For more advanced functionality you may wish to use other facilities to resolve the host name outside of the functionality offered here.

Throws:
ChameleonException

getId

public int getId()
          throws ChameleonException

A unique ID for all connection objects.

This ID is generated sequentially (i.e. 0, 1, 2, 3, etc.) for all connections received from a LlpServer, beginning at 0 when the application starts. The ID is globally unique and will allow users to identify connections from the same client, or connections from different clients.

Throws:
ChameleonException

getRemoteIpAddress

public int getRemoteIpAddress()
                       throws ChameleonException

The IP address of the remote host in host byte order.

Consider using RemoteIpAddressAsString instead for a more usable format.

Throws:
ChameleonException

getRemoteIpAddressAsString

public java.lang.String getRemoteIpAddressAsString()
                                            throws ChameleonException

The IP address of the remote host as a string.

See also RemoteIpAddress.

Throws:
ChameleonException

transmitMessage

public void transmitMessage(java.lang.String Message)
                     throws ChameleonException

Send a message to the client, prefixed and postfixed by the current HeaderBlock and TrailerBlock characters.

The data is not guaranteed to be received after this function is called. All data is buffered internally; completion of this call does not signify reception of data.

Function requires a running message loop (see runMessageLoop).

Blocking: Function does not block.
Events: If an error occurs during the send operation, an clientErrorReceived event results, containing the error message indicating why the send attempt has failed.

Parameters:
Message - HL7 message to send to a client connection in plain string format.
Throws:
ChameleonException

disconnect

public void disconnect()
                throws ChameleonException

Attempt to gracefully disconnect from the server.

A graceful disconnect implies a shutdown to the write end of the connection, and reading all data until the peer issues a close to its write end.

Note that the peer may not actually close the write end of its connection (although this is rare), which results in the connection never receiving the close event to signify that the connection is closed. In this situation, it is recommended that hardDisconnect be called to close the connection.

Function requires a running message loop (see runMessageLoop).

Blocking: Function does not block.
Events: If the close succeeds (the peer closes the connection), a clientDisconnected event results. If an error occurs during the close operation, an clientErrorReceived event results, containing the error message indicating why the close attempt failed.

Throws:
ChameleonException

hardDisconnect

public void hardDisconnect()
                    throws ChameleonException

Ungracefully disconnect without doing TCP/IP handshaking with the server.

If there is data pending on the network buffer to be sent, the peer will receive a reset on the connection if it attempts to read or write to the connection.

Blocking: Function blocks; upon returning, the connection is closed.
Events: None.

Throws:
ChameleonException