XPMP2
X-Plane multiplayer library 2 - using instancing
Classes | Namespaces | Enumerations | Functions | Variables
XPMPRemote.h File Reference

Semi-public remote network functionality for master/client operations. More...

#include <cassert>
#include <cstdint>
#include <cstring>
#include <cmath>
#include <array>
#include <algorithm>

Go to the source code of this file.

Classes

struct  XPMP2::RemoteDataRefPackTy
 Definition for how to map dataRef values to (u)int8, ie. to an integer range of 8 bits. More...
 
struct  XPMP2::RemoteMsgBaseTy
 Message header, identical for all message types. More...
 
struct  XPMP2::RemoteMsgBeaconTy
 "Beacon of Interest", ie. some message on the multicast just to wake up sender More...
 
struct  XPMP2::RemoteMsgSettingsTy
 Settings message, identifying a sending plugin, regularly providing its settings. More...
 
struct  XPMP2::RemoteAcDetailTy
 A/C details, packed into an array message. More...
 
struct  XPMP2::RemoteMsgAcDetailTy
 A/C detail message, has an inherited header plus an array of XPMP2::RemoteAcDetailTy elements. More...
 
struct  XPMP2::RemoteAcPosUpdateTy
 A/C Position updates based on global coordinates. More...
 
struct  XPMP2::RemoteMsgAcPosUpdateTy
 A/C detail message, has an inherited header plus an array of XPMP2::RemoteAcDetailTy elements. More...
 
struct  XPMP2::RemoteAcAnimTy
 A/C animation dataRef changes. More...
 
struct  XPMP2::RemoteAcAnimTy::DataRefValTy
 dataRef animation types and value More...
 
struct  XPMP2::RemoteMsgAcAnimTy
 A/C animation dataRef message, has an inherited header plus an array of variable sized XPMP2::RemoteAcAnimTy elements. More...
 
struct  XPMP2::RemoteAcRemoveTy
 A/C Removal only includes the plane id, structure required for msgSize() function. More...
 
struct  XPMP2::RemoteMsgAcRemoveTy
 A/C removal message, an array of plane ids. More...
 
struct  XPMP2::RemoteCBFctTy
 Function prototypes for callback functions to handle the received messages. More...
 

Namespaces

 XPMP2
 

Enumerations

enum  XPMP2::RemoteMsgTy : std::uint8_t {
  XPMP2::RMT_MSG_INTEREST_BEACON = 0 , XPMP2::RMT_MSG_SEND , XPMP2::RMT_MSG_SETTINGS , XPMP2::RMT_MSG_AC_DETAILED ,
  XPMP2::RMT_MSG_AC_POS_UPDATE , XPMP2::RMT_MSG_AC_ANIM , XPMP2::RMT_MSG_AC_REMOVE
}
 Message type. More...
 
enum  XPMP2::RemoteStatusTy : unsigned {
  XPMP2::REMOTE_OFF = 0 , XPMP2::REMOTE_SEND_WAITING , XPMP2::REMOTE_SENDING , XPMP2::REMOTE_RECV_WAITING ,
  XPMP2::REMOTE_RECEIVING
}
 State of remote communcations. More...
 

Functions

std::uint16_t XPMP2::PJWHash16 (const char *s)
 Produces a reproducible(!) hash value for strings. More...
 
CSLModel * XPMP2::CSLModelByPkgShortId (std::uint16_t _pkgHash, const std::string &_shortId)
 Find a model by package name hash and short id. More...
 
template<class T >
constexpr const T & XPMP2::clamp (const T &v, const T &lo, const T &hi)
 Clamps v between lo and hi: lo if v < lo, hi if hi < v, otherwise v More...
 
RemoteStatusTy XPMP2::RemoteGetStatus ()
 Returns the current Remote status. 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 const char * XPMP2::REMOTE_SIGNATURE = "TwinFan.plugin.XPMP2.Remote"
 The signature of the XPMP2 Remote Client. More...
 
const std::array< RemoteDataRefPackTy, V_COUNT > XPMP2::REMOTE_DR_DEF
 An array holding all dataRef packing definitions. More...
 
struct XPMP2::RemoteMsgBaseTy XPMP2::PACKED
 
constexpr std::uint8_t XPMP2::RMT_VER_BEACON = 0
 Interest Beacon message version number. More...
 
constexpr int XPMP2::REMOTE_SEND_SETTINGS_INTVL = 20
 How often to send settings? [s]. More...
 
constexpr std::uint8_t XPMP2::RMT_VER_SETTINGS = 0
 Setttings message version number. More...
 
constexpr std::uint8_t XPMP2::RMT_VER_AC_DETAIL = 1
 A/C detail message version number. More...
 
constexpr std::uint8_t XPMP2::RMT_VER_AC_POS_UPDATE = 0
 A/C Position update message version number. More...
 
constexpr double XPMP2::REMOTE_DEGREE_RES = 0.00000001
 What is the maximum difference a RemoteAcPosUpdateTy can hold? More...
 
constexpr double XPMP2::REMOTE_MAX_DIFF_DEGREE = REMOTE_DEGREE_RES * INT16_MAX
 maximum degree difference that can be represented in a pos update msg More...
 
constexpr double XPMP2::REMOTE_ALT_FT_RES = 0.01
 resolution of altitude[ft] updates More...
 
constexpr double XPMP2::REMOTE_MAX_DIFF_ALT_FT = REMOTE_ALT_FT_RES * INT16_MAX
 maximum altitude[ft] difference that can be represented in a pos update msg More...
 
constexpr float XPMP2::REMOTE_TIME_RES = 0.0001f
 resolution of time difference More...
 
constexpr float XPMP2::REMOTE_MAX_DIFF_TIME = REMOTE_TIME_RES * UINT16_MAX
 maximum time difference thatn can be represented in a pos update msg More...
 
constexpr std::uint8_t XPMP2::RMT_VER_AC_ANIM = 0
 A/C Position update message version number. More...
 
constexpr std::uint8_t XPMP2::RMT_VER_AC_REMOVE = 0
 A/C removal message version number. More...
 

Detailed Description

Semi-public remote network functionality for master/client operations.

Technically, this is public functionality from a library point of view. But it is intended for the "XPMP Remote Client" only, not for a standard plugin.
Network messages are packed for space efficiency, but also to avoid layout differences between compilers/platforms. However, manual layout tries to do reasonable alignment of numeric values and 8-byte-alignment of each structure, so that arrays of structures also align well.

Author
Birger Hoppe

Class Documentation

◆ XPMP2::RemoteAcAnimTy::DataRefValTy

struct XPMP2::RemoteAcAnimTy::DataRefValTy

dataRef animation types and value

Class Members
DR_VALS idx index into XPMP2::Aircraft::v
uint8_t v dataRef animation value