#include <H3DNetworkingUtils/RemoteUDPClient.h>
Public Member Functions | |
RemoteUDPClient () | |
Constructor. | |
virtual | ~RemoteUDPClient () |
Destructor. | |
Static Public Attributes | |
static const H3D::H3DFloat | PULSE_PERIOD = 1.0 |
The period between heartbeats for a UDP socket. | |
static H3D::H3DNodeDatabase | database |
X3D interface. | |
Protected Member Functions | |
virtual void | sendThisPacket (Packet &packet) |
Send a single packet. | |
virtual void | restartClient () |
Restarts the client reading and writing to a new socket. | |
virtual void | receiveLoop () |
Wait and receive packets. | |
virtual void | sendLoop () |
Send packets. Also send a 'pulse' packet, if no send has happened for a PULSE_PERIOD. | |
virtual void | requestClose () |
Request for the connection to close. |
It connects to a given server and port. It has a send loop, receive loop and a 'pulse' loop which tells the server it is still alive. Each loop runs in a different thread. At present, only one remote connection is handled at a time. IMPORTANT NOTE: Do not route from anything in the haptics loop to a remote field if you have periodicSend FALSE. This is because it will then try to send whenever the value changes - i.e. from the haptics loop itself. This will fail. You probably don't want it to interrupt haptics to do socket stuff anyway. Make sure you set periodic send true if you are routing in from the haptics thread. When the client first connects, it sends a pulse packet to the server. The servers responds with a pulse.
Examples:
void RemoteUDPClient::receiveLoop | ( | ) | [protected, virtual] |
Wait and receive packets.
while (true) {
Reimplemented from H3DNetworkingUtils::RemoteConnection.
References H3DNetworkingUtils::RemoteConnection::isConnected, H3DNetworkingUtils::Packet::isHeartBeat(), H3DNetworkingUtils::Packet::receive(), and requestClose().