XPMP2
X-Plane multiplayer library 2 - using instancing
Classes | Namespaces | Macros | Functions | Variables
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

 XPMP2
 

Macros

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

Variables

constexpr int XPMP2::REMOTE_RECV_BEACON_INTVL = 15
 How often to send an Interest Beacon? [s]. More...
 
constexpr float XPMP2::REMOTE_SEND_AC_DETAILS_INTVL = 10.f
 How often to send full a/c details? [s]. More...
 
mapRmtAcCacheTy XPMP2::gmapRmtAcCache
 Cache for last data sent out to the network. More...
 
unsigned XPMP2::gFullUpdDue = 0
 What's the full update group that has its turn now? More...
 
unsigned XPMP2::gFullUpdLastDone = 0
 the last actually processed full update group More...
 
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) More...
 
float XPMP2::gNow = 0.0f
 Current network timestamp. More...
 
float XPMP2::gNxtTxfTime = 0.0f
 When to actually process position updates next? More...
 
queueRmtDataTy XPMP2::gqueueRmtData
 the queue for passing data from main to network thread More...
 
std::condition_variable XPMP2::gcvRmtData
 notifies the network thread of available data to be processed More...
 
std::mutex XPMP2::gmutexRmtData
 
constexpr int XPMP2::MC_MAX_ERR =5
 after this many errors we no longer try listening More...
 
std::thread XPMP2::gThrMC
 remote listening/sending thread More...
 
UDPMulticast * XPMP2::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) More...
 
volatile bool XPMP2::gbStopMCThread = false
 Shall the network thread stop? More...
 
bool XPMP2::gbRemoteGaveUp = false
 No longer try remote functionality, have seen to many errors. More...
 
float XPMP2::gSendSettingsLast = 0.0f
 Timestamp when we sent our settings the last time. More...
 
RmtMsgBufTy< RemoteAcDetailTy, RMT_MSG_AC_DETAILED, RMT_VER_AC_DETAIL > XPMP2::gMsgAcDetail
 A/C Detail message. More...
 
RmtMsgBufTy< RemoteAcPosUpdateTy, RMT_MSG_AC_POS_UPDATE, RMT_VER_AC_POS_UPDATE > XPMP2::gMsgAcPosUpdate
 A/C Position Update message. More...
 
RmtMsgBufTy< RemoteAcAnimTy, RMT_MSG_AC_ANIM, RMT_VER_AC_ANIM > XPMP2::gMsgAcAnim
 A/C Animation dataRefs message. More...
 
RmtMsgBufTy< RemoteAcRemoveTy, RMT_MSG_AC_REMOVE, RMT_VER_AC_REMOVE > XPMP2::gMsgAcRemove
 A/C Removal message. More...
 
RemoteCBFctTy XPMP2::gRmtCBFcts
 The callback function pointers the remote client plugin provided. More...
 

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 
)    std::memcpy(to,from,std::min(sizeof(from),sizeof(to)))