#include <RPC3.h>
Inheritance diagram for RakNet::RPC3:
Public Member Functions | |
RPC3 () | |
Constructor. | |
virtual | ~RPC3 () |
Destructor. | |
void | SetNetworkIDManager (NetworkIDManager *idMan) |
template<typename Function> | |
bool | RegisterFunction (const char *uniqueIdentifier, Function functionPtr) |
bool | UnregisterFunction (const char *uniqueIdentifier) |
bool | IsFunctionRegistered (const char *uniqueIdentifier) |
void | SetTimestamp (RakNetTime timeStamp) |
void | SetSendParams (PacketPriority priority, PacketReliability reliability, char orderingChannel) |
void | SetRecipientAddress (SystemAddress systemAddress, bool broadcast) |
void | SetRecipientObject (NetworkID networkID) |
RakNetTime | GetLastSenderTimestamp (void) const |
SystemAddress | GetLastSenderAddress (void) const |
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) |
Protected Member Functions | |
void | OnAttach (RakPeerInterface *peer) |
virtual PluginReceiveResult | OnReceive (RakPeerInterface *peer, Packet *packet) |
virtual void | OnCloseConnection (RakPeerInterface *peer, SystemAddress systemAddress) |
virtual void | OnShutdown (RakPeerInterface *peer) |
void 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 |
bool RakNet::RPC3::RegisterFunction | ( | const char * | uniqueIdentifier, | |
Function | functionPtr | |||
) | [inline] |
[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 |
bool RPC3::UnregisterFunction | ( | const char * | uniqueIdentifier | ) |
Unregisters a function pointer to be callable given an identifier for the pointer
[in] | uniqueIdentifier | String identifying the function. |
bool RPC3::IsFunctionRegistered | ( | const char * | uniqueIdentifier | ) |
Returns if a function identifier was previously registered with RegisterFunction(), and not unregistered with UnregisterFunction()
[in] | uniqueIdentifier | String identifying the function. |
void RPC3::SetTimestamp | ( | RakNetTime | 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. |
void 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 RPC3::SetRecipientAddress | ( | SystemAddress | systemAddress, | |
bool | broadcast | |||
) |
Set system to send to for all following calls to Call() Defaults to UNASSIGNED_SYSTEM_ADDRESS, broadcast=true
[in] | systemAddress | See RakPeer::Send() |
[in] | broadcast | See RakPeer::Send() |
void 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() |
RakNetTime RPC3::GetLastSenderTimestamp | ( | void | ) | const |
If the last received function call has a timestamp included, it is stored and can be retrieved with this function.
SystemAddress 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
const char * RPC3::GetCurrentExecution | ( | void | ) | const |
Returns the currently running RPC call identifier, set from RegisterFunction::uniqueIdentifier Returns an empty string "" if none
bool RakNet::RPC3::Call | ( | const char * | uniqueIdentifier | ) | [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: 1. If the parameter is not a pointer 2. - And you overloaded RakNet::BitStream& operator<<(RakNet::BitStream& out, MyClass& in) then that will be used to do the serialization 3. - Otherwise, it will use bitStream.Write(myClass); BitStream already defines specializations for NetworkIDObject, SystemAddress, other BitStreams 4. If the parameter is a pointer 5. - And the pointer can be converted to NetworkIDObject, then it will write bitStream.Write(myClass->GetNetworkID()); To make it also dereference the pointer, use RakNet::_RPC3::Deref(myClass) 6. - And the pointer can not be converted to NetworkID, but it is a pointer to RakNet::RPC3, then it is skipped 7. Otherwise, the pointer is dereferenced and written as in step 2 and 3.
If the call fails on the remote system, you will get back ID_RPC_REMOTE_ERROR. packet->data[1] will contain one of the values of RPCErrorCodes. packet->data[2] and on will contain the name of the function.
[in] | uniqueIdentifier | parameter of the same name passed to RegisterFunction() on the remote system |
bool RakNet::RPC3::CallExplicit | ( | const char * | uniqueIdentifier, | |
const CallExplicitParameters *const | callExplicitParameters | |||
) | [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.
If the call fails on the remote system, you will get back ID_RPC_REMOTE_ERROR. packet->data[1] will contain one of the values of RPCErrorCodes. packet->data[2] and on will contain the name of the function.
[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() |
void RPC3::OnAttach | ( | RakPeerInterface * | peer | ) | [protected, virtual] |
Called when the interface is attached
[in] | peer | the instance of RakPeer that is calling Receive |
Reimplemented from PluginInterface.
PluginReceiveResult RPC3::OnReceive | ( | RakPeerInterface * | peer, | |
Packet * | packet | |||
) | [protected, virtual] |
OnReceive is called for every packet.
[in] | peer | the instance of RakPeer that is calling Receive |
[in] | packet | the packet that is being returned to the user |
Reimplemented from PluginInterface.
void RPC3::OnCloseConnection | ( | RakPeerInterface * | peer, | |
SystemAddress | systemAddress | |||
) | [protected, virtual] |
Called when a connection is dropped because the user called RakPeer::CloseConnection() for a particular system
[in] | peer | the instance of RakPeer that is calling Receive |
[in] | systemAddress | The system whose connection was closed |
Reimplemented from PluginInterface.
void RPC3::OnShutdown | ( | RakPeerInterface * | peer | ) | [protected, virtual] |
Called when RakPeer is shutdown
[in] | peer | the instance of RakPeer that is calling Receive |
Reimplemented from PluginInterface.