|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.interfaceware.chameleon.LlpConnection
public class LlpConnection
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 |
---|
public LlpConnection() throws ChameleonException
ChameleonException
public LlpConnection(long Handle) throws ChameleonException
ChameleonException
Method Detail |
---|
public void release() throws ChameleonException
ChameleonException
protected void finalize() throws ChameleonException
finalize
in class java.lang.Object
ChameleonException
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.
ChameleonException
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.
ChameleonException
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.
ChameleonException
public java.lang.String getRemoteIpAddressAsString() throws ChameleonException
The IP address of the remote host as a string.
See also RemoteIpAddress
.
ChameleonException
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.
Message
- HL7 message to send to a client connection in plain string
format.
ChameleonException
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.
ChameleonException
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.
ChameleonException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |