[raknet] Implement RPCMap::AddIdentifierWithFunction

This commit is contained in:
RD42 2024-01-04 23:25:36 +08:00
parent c8b7097a57
commit e0d4481671
4 changed files with 77 additions and 0 deletions

View File

@ -13,4 +13,9 @@ typedef unsigned int RakNetTime;
typedef long long RakNetTimeNS;
#endif
struct RPCParameters
{
char _gap0; // TODO: RPCParameters
};
#endif

14
raknet/RPCMap.cpp Normal file
View File

@ -0,0 +1,14 @@
// TODO: Implement RPCMap.cpp
// Called from the user thread for the local system
void RPCMap::AddIdentifierWithFunction(unsigned char uniqueIdentifier, void *functionPointer, bool isPointerToMember)
{
RPCNode *node;
node = new RPCNode;
node->uniqueIdentifier = uniqueIdentifier;
node->functionPointer=functionPointer;
node->isPointerToMember=isPointerToMember;
rpcSet[uniqueIdentifier] = node;
}

19
raknet/RPCMap.h Normal file
View File

@ -0,0 +1,19 @@
// TODO: Implement RPCMap.h
#ifndef __RPC_MAP
#define __RPC_MAP
#include "RPCNode.h"
#include "Export.h"
#define RPC_MAP_SIZE 256
struct RAK_DLL_EXPORT RPCMap
{
public:
void AddIdentifierWithFunction(unsigned char uniqueIdentifier, void *functionPointer, bool isPointerToMember);
protected:
RPCNode *rpcSet[RPC_MAP_SIZE];
};
#endif

39
raknet/RPCNode.h Normal file
View File

@ -0,0 +1,39 @@
// TODO: Implement RPCNode.h
#ifndef __RPC_NODE
#define __RPC_NODE
#include "NetworkTypes.h"
#include "Export.h"
/// \defgroup RAKNET_RPC Remote Procedure Call Subsystem
/// \brief A system to call C or object member procudures on other systems, and even to return return values.
/// \ingroup RAKNET_RPC
/// \internal
///
/// \brief Map registered procedure inside of a peer.
///
struct RAK_DLL_EXPORT RPCNode
{
/// String identifier of the RPC
unsigned char uniqueIdentifier
/// Force casting of member functions to void *
union
{
void ( *staticFunctionPointer ) ( RPCParameters *rpcParms );
#if (defined(__GNUC__) || defined(__GCCXML__))
void (*memberFunctionPointer)(void* _this, RPCParameters *rpcParms);
#else
void (__cdecl *memberFunctionPointer)(void* _this, RPCParameters *rpcParms);
#endif
void *functionPointer;
};
/// Is this a member function pointer? True if so. If false it's a regular C function.
bool isPointerToMember;
};
#endif