Intro
The Connection class is a cross platform DIS centric socket class. It was introduced in version 2-1-0.
The Connection class features:
- Broadcast and Multicast support
- Blocking or None blocking mode
- Tested on Windows & Linux
- Support for traditional socket use(KSockets technique) and also an event method based on the Publish/Subscriber design pattern
- Support for IP address based filtering
- Support for custom PDU factories(Decoders).
Note: The Connection class is part of a new namespace called NETWORK.
Includes
#include "KDIS/Network/Connection.h"
Connection Subscriber
The connection subscriber is based on the [Publish/Subscriber design pattern](http://en.wikipedia.org/wiki/Publish/subscribe).
We have 3 events we can subscribe to:
- OnDataReceived is called when data is received on the network and is called before the data is decoded and turned into a PDU. We can use this event to stop the data being processed by returning false. This allows for a simple IP Filter to be implemented.
- OnPDUReceived is called after OnDataReceived(providing true was returned). The data has now been decoded into a PDU and can be handled here. Note: By default this pointer is deleted once all OnPDUReceived event have been fired.
- OnPDUTransmit is called when a PDU is sent using the Connection class. This event can also make changes to the PDU before it is sent, such as setting the timestamp.
Examples
[PDU_Factory2]
This example shows how the ConnectionSubscriber can be used when receiving data.