#include <CHMllpServer.h>
Most of the network events that are raised provide a CHMllpConnection parameter, which gives methods to interact with the client connection that the event is associated with.
See http://www.interfaceware.com/manual/network_components.html for more information.
Public Member Functions | |
CHMllpServer () | |
Constructor. | |
virtual | ~CHMllpServer () |
Destructor. | |
CHMlistenerHandle | GetHandle () const |
This method is part of the internal implementation of this class and should not be called. | |
CHMint32 | Port () const |
The port on which we are listening, set by the CHMllpServer::StartListen method. | |
const char * | Host () const |
The local interface on which we are listening, used by the next call to the CHMllpServer::StartListen method. | |
void | SetHost (const char *Value) |
Set method for host. | |
const char * | HeaderBlock () const |
The characters that precede a message in a stream. | |
void | SetHeaderBlock (const char *Value) |
Set method for headerBlock. | |
const char * | TrailerBlock () const |
The characters that follow a message in a stream. | |
void | SetTrailerBlock (const char *Value) |
Set method for trailerBlock. | |
CHMboolean | IsListening () const |
The status of the listening state. | |
CHMllpConnection | Client (CHMint32 ClientIndex) const |
Representation of the collection of remote Clients that are connected to this server. | |
CHMint32 | CountOfClient () const |
Returns the total number of Clients. | |
void | StopMessageLoop () |
This will send a quit message to the thread that the networking components are running on. | |
void | StartListen (CHMint32 Port) |
Attempt to listen on the supplied port for incoming client connections. | |
const char * | MakeMessagePrintable (const char *InputString, const char *NewLine, CHMint32 MaximumLength) |
Make message printable by changing plain carriage return characters "\r" to carriage return and newline characters "\r\n". | |
void | StopListen () |
Stop the component from listening for new connections. | |
void | DisconnectAllClients () |
Stop listening on the port for new connections, and initiate a CHMllpConnection::Disconnect on all open connections. | |
virtual void | OnErrorReceived (const char *ErrorMessage, CHMint32 Code)=0 |
Fired when an issue occurs with the server socket itself rather than a specific client. | |
virtual void | OnClientConnected (CHMllpConnection &Client)=0 |
Fired when a connection is made to the server by a new client. | |
virtual void | OnClientDisconnected (CHMllpConnection &Client)=0 |
Fired when a client disconnects from the server, or a previous CHMllpConnection::Disconnect call on a Connection succeeds. | |
virtual void | OnClientErrorReceived (CHMllpConnection &Client, const char *ErrorMessage, CHMint32 ErrorCode)=0 |
Fired when a networking error occurs with a specific client connection. | |
virtual void | OnMessageReceived (CHMllpConnection &Client, const char *Message)=0 |
Fired each time we receive a message from a connected HL7 client. | |
virtual void | OnDataIgnored (CHMllpConnection &Client, const char *Data)=0 |
Fired when data has been received that is not within the header and trailer block envelope. | |
Static Public Member Functions | |
static void | RunMessageLoop () |
On Unix and Linux platforms events are dispatched using a loop based on the select function. |
|
Constructor.
|
|
Destructor.
|
|
Representation of the collection of remote Clients that are connected to this server. This list changes in size as connections are received or closed, or if an error occurs on the connection (which implies a close). Users cannot change the size or append to the contents of this collection since it is managed internally. References to CHMllpConnection objects within this collection should not be maintained. Instead, always access CHMllpConnection objects through this collection interface, or the event to which CHMllpConnection objects are passed as parameters.
|
|
Returns the total number of Clients. See also the CHMllpServer::Client property. |
|
Stop listening on the port for new connections, and initiate a CHMllpConnection::Disconnect on all open connections. This function requires a running message loop (see CHMllpServer::RunMessageLoop).
Blocking: Function blocks until CHMllpConnection::Disconnect is called on all open connections. This implies that the connections are not necessarily closed when this function returns. |
|
This method is part of the internal implementation of this class and should not be called.
|
|
The characters that precede a message in a stream. The default value for this property is 0x0B as defined by the the LLP protocol. This property is used both for parsing out the incoming data streams and wrapping outgoing messages. See also the CHMllpServer::SetHeaderBlock method. |
|
The local interface on which we are listening, used by the next call to the CHMllpServer::StartListen method. The default is an empty string, which means the listener will listen on all local interfaces. It must be in the Internet standard "." (dotted) notation (e.g. 127.0.0.1). See also the CHMllpServer::SetHost method. |
|
The status of the listening state. Returns true if the server is currently listening for connections.
Blocking: Function blocks until the listening state is determined. |
|
Make message printable by changing plain carriage return characters "\r" to carriage return and newline characters "\r\n". HL7 messages use the carriage return character "\r" to separate the segments. This makes it difficult to print them out in console windows because the cursor overwrites each previous segment instead of moving on to a newline for each segment. This method is intended to be a simple utility method to make it easier to convert HL7 messages into a printable format. This function also allows the output string to be truncated.
|
|
Fired when a connection is made to the server by a new client. This event is useful for logging.
|
|
Fired when a client disconnects from the server, or a previous CHMllpConnection::Disconnect call on a Connection succeeds. This event is useful for logging.
|
|
Fired when a networking error occurs with a specific client connection. The context on when this is received is often determined by a previous operation, although that is not necessary. The connection will always be closed once this event is received so there is no need to close the connection within the application code.
|
|
Fired when data has been received that is not within the header and trailer block envelope. This is for dealing with an incorrect LLP implementation. The data is provided to the user's application through this event. This allows it to be logged since this is likely to be a very significant error with the counterparty's LLP implementation.
|
|
Fired when an issue occurs with the server socket itself rather than a specific client.
|
|
Fired each time we receive a message from a connected HL7 client. Typically, the message should be processed and only then should an HL7 ACKnowledgement message be sent. Received without any Trailer or Header characters.
|
|
The port on which we are listening, set by the CHMllpServer::StartListen method.
|
|
On Unix and Linux platforms events are dispatched using a loop based on the select function. All POSIX applications require this function to be called in order to start receiving events. On Windows platforms all events are dispatched using the Windows message loop. Graphical Windows applications contain a running Windows message loop; therefore, this function will not need to be called. Console applications require this function to be called in order to start receiving events.
Throws: Function will throw an exception only if the operating system reports an error. |
|
Set method for headerBlock. See CHMllpServer::HeaderBlock.
|
|
Set method for host. See CHMllpServer::Host.
|
|
Set method for trailerBlock. See CHMllpServer::TrailerBlock.
|
|
Attempt to listen on the supplied port for incoming client connections. This function requires a running message loop (see CHMllpServer::RunMessageLoop) in order to receive connections.
Blocking: Function blocks until a port can be successfully listened on or an error occurs. By default, the listener will listen on all local interfaces. To make it listen on a specific local interface use the CHMllpServer::Host property to set the IP address of the interface to use.
|
|
Stop the component from listening for new connections. Note that any existing connections that have already been established are NOT closed. In order to properly disconnect existing connections as well as stop listening, use CHMllpServer::DisconnectAllClients.
Blocking: Function blocks until the stop listen succeeds. |
|
This will send a quit message to the thread that the networking components are running on. Under Windows, this is a WM_QUIT message. All the networking components must be created on a single thread with a running message loop. For more information, see the CHMllpServer::RunMessageLoop method. |
|
The characters that follow a message in a stream. The default value is the character 0x1C followed by 0x0D as defined by the LLP protocol. This property is used both for parsing out the incoming data streams and wrapping outgoing messages. See also the CHMllpServer::SetTrailerBlock method. |