RakNet
4.0
|
The RPC3 plugin allows you to call remote functions as if they were local functions, using the standard function call syntax. More...
#include <RPC3.h>
Public Member Functions | |
void | SetNetworkIDManager (NetworkIDManager *idMan) |
template<typename Function > | |
bool | RegisterFunction (const char *uniqueIdentifier, Function functionPtr) |
template<typename Function > | |
void | RegisterSlot (const char *sharedIdentifier, Function functionPtr, NetworkID objectInstanceId, int callPriority) |
bool | UnregisterFunction (const char *uniqueIdentifier) |
bool | IsFunctionRegistered (const char *uniqueIdentifier) |
void | SetTimestamp (RakNet::Time timeStamp) |
void | SetSendParams (PacketPriority priority, PacketReliability reliability, char orderingChannel) |
void | SetRecipientAddress (const SystemAddress &systemAddress, bool broadcast) |
void | SetRecipientObject (NetworkID networkID) |
RakNet::Time | GetLastSenderTimestamp (void) const |
SystemAddress | GetLastSenderAddress (void) const |
void | InterruptSignal (void) |
If called while processing a slot, no further slots for the currently executing signal will be executed. | |
RakPeerInterface * | GetRakPeer (void) const |
Returns the instance of RakPeer this plugin was attached to. | |
const char * | GetCurrentExecution (void) const |
bool | Call (const char *uniqueIdentifier) |
bool | CallExplicit (const char *uniqueIdentifier, const CallExplicitParameters *const callExplicitParameters) |
bool | Signal (const char *sharedIdentifier) |
bool | SignalExplicit (const char *sharedIdentifier, const SignalExplicitParameters *const signalExplicitParameters) |
Same as Signal(), but you are forced to specify the remote system parameters. | |
void | InvokeSignal (DataStructures::HashIndex functionIndex, RakNet::BitStream *serializedParameters, bool temporarilySetUSA) |
Call a given signal with a bitstream representing the parameter list. | |
![]() | |
virtual void | OnDetach (void) |
Called when the interface is detached. | |
virtual void | Update (void) |
Update is called every time a packet is checked for . | |
virtual void | OnRakPeerStartup (void) |
Called when RakPeer is initialized. | |
virtual void | OnRakPeerShutdown (void) |
Called when RakPeer is shutdown. | |
virtual void | OnNewConnection (const SystemAddress &systemAddress, RakNetGUID rakNetGUID, bool isIncoming) |
virtual void | OnFailedConnectionAttempt (Packet *packet, PI2_FailedConnectionAttemptReason failedConnectionAttemptReason) |
virtual bool | UsesReliabilityLayer (void) const |
virtual void | OnDirectSocketSend (const char *data, const BitSize_t bitsUsed, SystemAddress remoteSystemAddress) |
virtual void | OnDirectSocketReceive (const char *data, const BitSize_t bitsUsed, SystemAddress remoteSystemAddress) |
virtual void | OnReliabilityLayerNotification (const char *errorMessage, const BitSize_t bitsUsed, SystemAddress remoteSystemAddress, bool isError) |
virtual void | OnInternalPacket (InternalPacket *internalPacket, unsigned frameNumber, SystemAddress remoteSystemAddress, RakNet::TimeMS time, int isSend) |
virtual void | OnAck (unsigned int messageNumber, SystemAddress remoteSystemAddress, RakNet::TimeMS time) |
virtual void | OnPushBackPacket (const char *data, const BitSize_t bitsUsed, SystemAddress remoteSystemAddress) |
Protected Member Functions | |
void | OnAttach (void) |
Called when the interface is attached. | |
virtual PluginReceiveResult | OnReceive (Packet *packet) |
virtual void | OnClosedConnection (const SystemAddress &systemAddress, RakNetGUID rakNetGUID, PI2_LostConnectionReason lostConnectionReason) |
Protected Attributes | |
unsigned int | nextSlotRegistrationCount |
Used so slots are called in the order they are registered. | |
The RPC3 plugin allows you to call remote functions as if they were local functions, using the standard function call syntax.
No serialization or deserialization is needed.
As of this writing, the system is not threadsafe.
Features:
Pointers to classes that derive from NetworkID are automatically looked up using NetworkIDManager Types are written to BitStream, meaning built-in serialization operations are performed, including endian swapping Types can customize autoserialization by providing an implementation of operator << and operator >> to and from BitStream
|
inline |
Calls a remote function, using as send parameters whatever was last passed to SetTimestamp(), SetSendParams(), SetRecipientAddress(), and SetRecipientObject() If you call a C++ class member function, don't forget to first call SetRecipientObject(). You can use CallExplicit() instead of Call() to force yourself not to forget.
Parameters passed to Call are processed as follows:
[in] | uniqueIdentifier | parameter of the same name passed to RegisterFunction() on the remote system |
|
inline |
Calls a remote function, using whatever was last passed to SetTimestamp(), SetSendParams(), SetRecipientAddress(), and SetRecipientObject() Passed parameter(s), if any, are serialized using operator << with RakNet::BitStream. If you provide an overload it will be used, otherwise the seriailzation is equivalent to memcpy except for native RakNet types (NetworkIDObject, SystemAddress, etc.) If the type is a pointer to a type deriving from NetworkIDObject, then only the NetworkID is sent, and the object looked up on the remote system. Otherwise, the pointer is dereferenced and the contents serialized as usual.
[in] | uniqueIdentifier | parameter of the same name passed to RegisterFunction() on the remote system |
[in] | timeStamp | See SetTimestamp() |
[in] | priority | See SetSendParams() |
[in] | reliability | See SetSendParams() |
[in] | orderingChannel | See SetSendParams() |
[in] | systemAddress | See SetRecipientAddress() |
[in] | broadcast | See SetRecipientAddress() |
[in] | networkID | See SetRecipientObject() |
const char* RakNet::RPC3::GetCurrentExecution | ( | void | ) | const |
Returns the currently running RPC call identifier, set from RegisterFunction::uniqueIdentifier Returns an empty string "" if none
SystemAddress RakNet::RPC3::GetLastSenderAddress | ( | void | ) | const |
Returns the system address of the last system to send us a received function call Equivalent to the old system RPCParameters::sender
RakNet::Time RakNet::RPC3::GetLastSenderTimestamp | ( | void | ) | const |
If the last received function call has a timestamp included, it is stored and can be retrieved with this function.
bool RakNet::RPC3::IsFunctionRegistered | ( | const char * | uniqueIdentifier | ) |
Returns if a function identifier was previously registered on this system with RegisterFunction(), and not unregistered with UnregisterFunction()
[in] | uniqueIdentifier | String identifying the function. |
|
protectedvirtual |
Called when a connection is dropped because the user called RakPeer::CloseConnection() for a particular system
[in] | systemAddress | The system whose connection was closed |
[in] | rakNetGuid | The guid of the specified system |
[in] | lostConnectionReason | How the connection was closed: manually, connection lost, or notification of disconnection |
Reimplemented from RakNet::PluginInterface2.
|
protectedvirtual |
OnReceive is called for every packet.
[in] | packet | the packet that is being returned to the user |
Reimplemented from RakNet::PluginInterface2.
|
inline |
Register a function pointer as callable using RPC()
[in] | uniqueIdentifier | String identifying the function. Recommended that this is the name of the function |
[in] | functionPtr | Pointer to the function. For C, just pass the name of the function. For C++, use ARPC_REGISTER_CPP_FUNCTION |
|
inline |
Register a slot, which is a function pointer to one or more instances of a class that supports this function signature When a signal occurs, all slots with the same identifier are called.
[in] | sharedIdentifier | A string to identify the slot. Recommended to be the same as the name of the function. |
[in] | functionPtr | Pointer to the function. For C, just pass the name of the function. For C++, use ARPC_REGISTER_CPP_FUNCTION |
[in] | objectInstance | If 0, then this slot is just a regular C function. Otherwise, this is a member of the given class instance. |
[in] | callPriority | Slots are called by order of the highest callPriority first. For slots with the same priority, they are called in the order they are registered |
void RakNet::RPC3::SetNetworkIDManager | ( | NetworkIDManager * | idMan | ) |
Sets the network ID manager to use for object lookup Required to call C++ object member functions via SetRecipientObject()
[in] | idMan | Pointer to the network ID manager to use |
void RakNet::RPC3::SetRecipientAddress | ( | const SystemAddress & | systemAddress, |
bool | broadcast | ||
) |
Set system to send to for all following calls to Call() Defaults to RakNet::UNASSIGNED_SYSTEM_ADDRESS, broadcast=true
[in] | systemAddress | See RakPeer::Send() |
[in] | broadcast | See RakPeer::Send() |
void RakNet::RPC3::SetRecipientObject | ( | NetworkID | networkID | ) |
Set the NetworkID to pass for all following calls to Call() Defaults to UNASSIGNED_NETWORK_ID (none) If set, the remote function will be considered a C++ function, e.g. an object member function If set to UNASSIGNED_NETWORK_ID (none), the remote function will be considered a C function If this is set incorrectly, you will get back either RPC_ERROR_CALLING_C_AS_CPP or RPC_ERROR_CALLING_CPP_AS_C
[in] | networkID | Returned from NetworkIDObject::GetNetworkID() |
void RakNet::RPC3::SetSendParams | ( | PacketPriority | priority, |
PacketReliability | reliability, | ||
char | orderingChannel | ||
) |
Set parameters to pass to RakPeer::Send() for all following calls to Call() Deafults to HIGH_PRIORITY, RELIABLE_ORDERED, ordering channel 0
[in] | priority | See RakPeer::Send() |
[in] | reliability | See RakPeer::Send() |
[in] | orderingChannel | See RakPeer::Send() |
void RakNet::RPC3::SetTimestamp | ( | RakNet::Time | timeStamp | ) |
Send or stop sending a timestamp with all following calls to Call() Use GetLastSenderTimestamp() to read the timestamp.
[in] | timeStamp | Non-zero to pass this timestamp using the ID_TIMESTAMP system. 0 to clear passing a timestamp. |
|
inline |
Calls zero or more functions identified by sharedIdentifier. Uses as send parameters whatever was last passed to SetTimestamp(), SetSendParams(), and SetRecipientAddress() You can use CallExplicit() instead of Call() to force yourself not to forget to set parameters
See the Call() function for a description of parameters
[in] | sharedIdentifier | parameter of the same name passed to RegisterSlot() on the remote system |
bool RakNet::RPC3::UnregisterFunction | ( | const char * | uniqueIdentifier | ) |
Unregisters a function pointer to be callable given an identifier for the pointer
[in] | uniqueIdentifier | String identifying the function. |