XPMP2
X-Plane multiplayer library 2 - using instancing
Remote.cpp File Reference

Master/Client communication for aircraft synchronization on remote networked instances. More...

#include "XPMP2.h"

Classes

struct  XPMP2::RemoteAcDetailTy_v0
 Version 0 A/C details, packed into an array message. More...
 
struct  XPMP2::RemoteMsgAcDetailTy_v0
 Version 0 A/C detail message, has an inherited header plus an array of XPMP2::RemoteAcDetailTy elements. More...
 

Namespaces

namespace  XPMP2
 

Macros

#define memcpy_min(to, from)
 
#define INFO_MC_SEND_WAIT   "Listening to %s, waiting for someone being interested in our data..."
 
#define INFO_MC_SEND_RCVD   "Received word from %s, will start sending aircraft data"
 
#define ERR_MC_THREAD   "Exception in multicast handling: %s"
 
#define ERR_MC_MAX   "Too many errors, I give up on remote functionality!"
 
#define INFO_MC_RECV_BEGIN   "Receiver started listening to %s"
 
#define INFO_MC_RECV_RCVD   "Receiver received data from %.*s on %s, will start message processing"
 

Functions

std::unique_lock< std::mutex > XPMP2::glockRmtData (gmutexRmtData)
 The lock that we keep during handling of the flight loop.
 
bool XPMP2::RmtSendContinue ()
 Conditions for continued send operation.
 
void XPMP2::RmtSendProcessQueue ()
 Process the data passed down to us in the queue.
 
void XPMP2::RmtSendSettings ()
 Send our settings.
 
void XPMP2::RmtSendLoop ()
 Sending function, ie. we are actively sending data out.
 
void XPMP2::RmtSendMain ()
 Thread main function for the sender.
 
void XPMP2::RmtSendBeacon ()
 Sends an Interest Beacon.
 
bool XPMP2::RmtRecvContinue ()
 Conditions for continued receive operation.
 
void XPMP2::RmtRecvMain ()
 Thread main function for the receiver.
 
void XPMP2::RmtStartMCThread (bool bSender)
 Start the background thread to listen to multicast, to see if anybody is interested in our data.
 
void XPMP2::RmtStopAll ()
 Stop all threads and communication with the network.
 
void XPMP2::RemoteInit ()
 Initialize the module.
 
void XPMP2::RemoteCleanup ()
 Grace cleanup, stops all threads.
 
RemoteStatusTy XPMP2::RemoteGetStatus ()
 Returns the current Remote status.
 
void XPMP2::RemoteSenderUpdateStatus ()
 Compares current vs. expected status and takes appropriate action.
 
void XPMP2::RemoteAcEnqueueStarts (float now)
 
void XPMP2::RemoteAcEnqueue (const Aircraft &ac)
 Regularly called from the flight loop callback to send a/c date onto the network.
 
void XPMP2::RemoteAcEnqueueDone ()
 Informs us that all a/c have been processed: All pending messages to be sent now.
 
void XPMP2::RemoteAcRemove (const Aircraft &ac)
 Informs us about an aircraft deletion.
 
void XPMP2::RemoteAcClearAll ()
 Informs us that there are no more aircraft, clear our caches!
 
void XPMP2::RemoteRecvStart (const RemoteCBFctTy &_rmtCBFcts)
 Starts the listener, will call provided callback functions with received messages.
 
void XPMP2::RemoteRecvStop ()
 Stops the receiver.
 

Variables

constexpr int XPMP2::REMOTE_RECV_BEACON_INTVL = 15
 How often to send an Interest Beacon? [s].
 
constexpr float XPMP2::REMOTE_SEND_AC_DETAILS_INTVL = 10.f
 How often to send full a/c details? [s].
 
mapRmtAcCacheTy XPMP2::gmapRmtAcCache
 Cache for last data sent out to the network.
 
unsigned XPMP2::gFullUpdDue = 0
 What's the full update group that has its turn now?
 
unsigned XPMP2::gFullUpdLastDone = 0
 the last actually processed full update group
 
unsigned XPMP2::gNxtFullUpdGrpToAssign = 0
 What's the next group number to assign to the next a/c? (Assigned will be the value incremented by 1)
 
float XPMP2::gNow = 0.0f
 Current network timestamp.
 
float XPMP2::gNxtTxfTime = 0.0f
 When to actually process position updates next?
 
queueRmtDataTy XPMP2::gqueueRmtData
 the queue for passing data from main to network thread
 
std::condition_variable XPMP2::gcvRmtData
 notifies the network thread of available data to be processed
 
std::mutex XPMP2::gmutexRmtData
 
constexpr int XPMP2::MC_MAX_ERR =5
 after this many errors we no longer try listening
 
std::thread XPMP2::gThrMC
 remote listening/sending thread
 
UDPMulticastXPMP2::gpMc = nullptr
 multicast socket for listening/sending (destructor uses locks, which don't work during module shutdown, so can't create a global object due to its exit-time destructor)
 
volatile bool XPMP2::gbStopMCThread = false
 Shall the network thread stop?
 
bool XPMP2::gbRemoteGaveUp = false
 No longer try remote functionality, have seen to many errors.
 
float XPMP2::gSendSettingsLast = 0.0f
 Timestamp when we sent our settings the last time.
 
RmtMsgBufTy< RemoteAcDetailTy, RMT_MSG_AC_DETAILED, RMT_VER_AC_DETAILXPMP2::gMsgAcDetail
 A/C Detail message.
 
RmtMsgBufTy< RemoteAcPosUpdateTy, RMT_MSG_AC_POS_UPDATE, RMT_VER_AC_POS_UPDATEXPMP2::gMsgAcPosUpdate
 A/C Position Update message.
 
RmtMsgBufTy< RemoteAcAnimTy, RMT_MSG_AC_ANIM, RMT_VER_AC_ANIMXPMP2::gMsgAcAnim
 A/C Animation dataRefs message.
 
RmtMsgBufTy< RemoteAcRemoveTy, RMT_MSG_AC_REMOVE, RMT_VER_AC_REMOVEXPMP2::gMsgAcRemove
 A/C Removal message.
 
RemoteCBFctTy XPMP2::gRmtCBFcts
 The callback function pointers the remote client plugin provided.
 

Detailed Description

Master/Client communication for aircraft synchronization on remote networked instances.

Author
Birger Hoppe

Macro Definition Documentation

◆ ERR_MC_MAX

#define ERR_MC_MAX   "Too many errors, I give up on remote functionality!"

◆ ERR_MC_THREAD

#define ERR_MC_THREAD   "Exception in multicast handling: %s"

◆ INFO_MC_RECV_BEGIN

#define INFO_MC_RECV_BEGIN   "Receiver started listening to %s"

◆ INFO_MC_RECV_RCVD

#define INFO_MC_RECV_RCVD   "Receiver received data from %.*s on %s, will start message processing"

◆ INFO_MC_SEND_RCVD

#define INFO_MC_SEND_RCVD   "Received word from %s, will start sending aircraft data"

◆ INFO_MC_SEND_WAIT

#define INFO_MC_SEND_WAIT   "Listening to %s, waiting for someone being interested in our data..."

◆ memcpy_min

#define memcpy_min ( to,
from )
Value:
std::memcpy(to,from,std::min(sizeof(from),sizeof(to)))