SLikeNet 0.1.3

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Enumerations
RPC
Plugins

Remote procedure calls, without external dependencies. More...

## Classes

class | SLNet::RPC4
| The RPC4 plugin is just an association between a C function pointer and a string. More...
struct | SLNet::RPC4::LocalCallback
struct | SLNet::RPC4::LocalSlot
struct | SLNet::RPC4::LocalSlotObject

## Enumerations

enum | SLNet::RPCErrorCodes { SLNet::RPC_ERROR_FUNCTION_NOT_REGISTERED }
| Error codes returned by a remote system as to why an RPC function call cannot execute. More...

## Detailed Description

Remote procedure calls, without external dependencies.

This should not be used at the same time as RPC3. This is a less functional version of RPC3, and is here for users that do not want the Boost dependency of RPC3.

## Class Documentation

class SLNet::RPC4

The RPC4 plugin is just an association between a C function pointer and a string.

It is for users that want to use RPC, but do not want to use boost. You do not have the automatic serialization or other features of RPC3, and C++ member calls are not supported.

Note
  You cannot use RPC4 at the same time as RPC3Plugin

Definition at line 79 of file RPC4Plugin.h.

Inheritance diagram for SLNet::RPC4:

### Public Member Functions

| RPC4 ()
virtual | ~RPC4 ()
bool | RegisterFunction (const char *uniqueID, void(*functionPointer)(SLNet::BitStream *userData, Packet *packet))
| Register a function pointer to be callable from a remote system.
void | RegisterSlot (const char *sharedIdentifier, void(*functionPointer)(SLNet::BitStream *userData, Packet *packet), int callPriority)
bool | RegisterBlockingFunction (const char *uniqueID, void(*functionPointer)(SLNet::BitStream *userData, SLNet::BitStream *returnData, Packet *packet))
| Same as RegisterFunction, but is called with CallBlocking() instead of Call() and returns a value to the caller.
void | RegisterLocalCallback (const char *uniqueID, MessageID messageId)
bool | UnregisterFunction (const char *uniqueID)
| Unregister a function pointer previously registered with RegisterFunction()
bool | UnregisterBlockingFunction (const char *uniqueID)
| Same as UnregisterFunction, except for a blocking function.
bool | UnregisterLocalCallback (const char *uniqueID, MessageID messageId)
bool | UnregisterSlot (const char *sharedIdentifier)
void | CallLoopback (const char *uniqueID, SLNet::BitStream *bitStream)
void | Call (const char *uniqueID, SLNet::BitStream *bitStream, PacketPriority priority, PacketReliability reliability, char orderingChannel, const AddressOrGUID systemIdentifier, bool broadcast)
bool | CallBlocking (const char *uniqueID, SLNet::BitStream *bitStream, PacketPriority priority, PacketReliability reliability, char orderingChannel, const AddressOrGUID systemIdentifier, SLNet::BitStream *returnData)
| Same as call, but don't return until the remote system replies. Broadcasting parameter does not exist, this can only call one remote system.
void | Signal (const char *sharedIdentifier, SLNet::BitStream *bitStream, PacketPriority priority, PacketReliability reliability, char orderingChannel, const AddressOrGUID systemIdentifier, bool broadcast, bool invokeLocal)
void | InterruptSignal (void)
| If called while processing a slot, no further slots for the currently executing signal will be executed.
Public Member Functions inherited from SLNet::PluginInterface2
| PluginInterface2 ()
virtual | ~PluginInterface2 ()
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 | OnClosedConnection (const SystemAddress &systemAddress, RakNetGUID rakNetGUID, PI2_LostConnectionReason lostConnectionReason)
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, SLNet::TimeMS time, int isSend)
virtual void | OnAck (unsigned int messageNumber, SystemAddress remoteSystemAddress, SLNet::TimeMS time)
virtual void | OnPushBackPacket (const char *data, const BitSize_t bitsUsed, SystemAddress remoteSystemAddress)
RakPeerInterface * | GetRakPeerInterface (void) const
RakNetGUID | GetMyGUIDUnified (void) const
void | SetRakPeerInterface (RakPeerInterface *ptr)
void | SetTCPInterface (TCPInterface *ptr)

### Static Public Member Functions

static int | LocalCallbackComp (const MessageID &key, LocalCallback *const &data)
static int | LocalSlotObjectComp (const LocalSlotObject &key, const LocalSlotObject &data)

### Public Attributes

DataStructures::Hash < SLNet::RakString, LocalSlot *, 256, SLNet::RakString::ToInteger > | localSlots

### Protected Member Functions

virtual void | OnAttach (void)
| Called when the interface is attached.
virtual PluginReceiveResult | OnReceive (Packet *packet)
DataStructures::HashIndex | GetLocalSlotIndex (const char *sharedIdentifier)
void | InvokeSignal (DataStructures::HashIndex functionIndex, SLNet::BitStream *serializedParameters, Packet *packet)
Protected Member Functions inherited from SLNet::PluginInterface2
void | SendUnified (const SLNet::BitStream *bitStream, PacketPriority priority, PacketReliability reliability, char orderingChannel, const AddressOrGUID systemIdentifier, bool broadcast)
void | SendUnified (const char *data, const int length, PacketPriority priority, PacketReliability reliability, char orderingChannel, const AddressOrGUID systemIdentifier, bool broadcast)
bool | SendListUnified (const char **data, const int *lengths, const int numParameters, PacketPriority priority, PacketReliability reliability, char orderingChannel, const AddressOrGUID systemIdentifier, bool broadcast)
Packet * | AllocatePacketUnified (unsigned dataSize)
void | PushBackPacketUnified (Packet *packet, bool pushAtHead)
void | DeallocPacketUnified (Packet *packet)

### Protected Attributes

DataStructures::Hash < SLNet::RakString, void(*)(SLNet::BitStream *, Packet *), 64, SLNet::RakString::ToInteger > | registeredNonblockingFunctions
DataStructures::Hash < SLNet::RakString, void(*)(SLNet::BitStream *, SLNet::BitStream *, Packet *), 64, SLNet::RakString::ToInteger > | registeredBlockingFunctions
DataStructures::OrderedList < MessageID, LocalCallback *, RPC4::LocalCallbackComp > | localCallbacks
SLNet::BitStream | blockingReturnValue
bool | gotBlockingReturnValue
unsigned int | nextSlotRegistrationCount
| Used so slots are called in the order they are registered.
bool | interruptSignal
Protected Attributes inherited from SLNet::PluginInterface2
RakPeerInterface * | rakPeerInterface
TCPInterface * | tcpInterface

#### Constructor & Destructor Documentation

SLNet::RPC4::RPC4 | ( |  | ) |

virtual SLNet::RPC4::~RPC4 | ( |  | ) |

virtual

#### Member Function Documentation

void SLNet::RPC4::Call | ( | const char * | uniqueID,
|  | SLNet::BitStream * | bitStream,
|  | PacketPriority | priority,
|  | PacketReliability | reliability,
|  | char | orderingChannel,
|  | const AddressOrGUID | systemIdentifier,
|  | bool | broadcast
| ) |  |

Deprecated:
  , use Signal() Send to the specified remote instance of RakPeer.

Parameters

  [in] | uniqueID | Identifier originally passed to RegisterFunction() on the remote system(s)
  [in] | bitStream | bitStream encoded data to send to the function callback
  [in] | priority | See RakPeerInterface::Send()
  [in] | reliability | See RakPeerInterface::Send()
  [in] | orderingChannel | See RakPeerInterface::Send()
  [in] | systemIdentifier | See RakPeerInterface::Send()
  [in] | broadcast | See RakPeerInterface::Send()

bool SLNet::RPC4::CallBlocking | ( | const char * | uniqueID,
|  | SLNet::BitStream * | bitStream,
|  | PacketPriority | priority,
|  | PacketReliability | reliability,
|  | char | orderingChannel,
|  | const AddressOrGUID | systemIdentifier,
|  | SLNet::BitStream * | returnData
| ) |  |

Same as call, but don't return until the remote system replies. Broadcasting parameter does not exist, this can only call one remote system.

Note
  This function does not return until the remote system responds, disconnects, or was never connected to begin with

Parameters

  [in] | Identifier | originally passed to RegisterBlockingFunction() on the remote system(s)
  [in] | bitStream | bitStream encoded data to send to the function callback
  [in] | priority | See RakPeerInterface::Send()
  [in] | reliability | See RakPeerInterface::Send()
  [in] | orderingChannel | See RakPeerInterface::Send()
  [in] | systemIdentifier | See RakPeerInterface::Send()
  [out] | returnData | Written to by the function registered with RegisterBlockingFunction.

Returns
  true if successfully called. False on disconnect, function not registered, or not connected to begin with

void SLNet::RPC4::CallLoopback | ( | const char * | uniqueID,
|  | SLNet::BitStream * | bitStream
| ) |  |

Deprecated:
  Use RegisterSlot() and Signal() with your own RakNetGUID as the send target Send to the attached instance of RakPeer. See RakPeerInterface::SendLoopback()

Parameters

  [in] | Identifier | originally passed to RegisterFunction() on the local system
  [in] | bitStream | bitStream encoded data to send to the function callback

DataStructures::HashIndex SLNet::RPC4::GetLocalSlotIndex | ( | const char * | sharedIdentifier | ) |

protected

void SLNet::RPC4::InterruptSignal | ( | void |  | ) |

If called while processing a slot, no further slots for the currently executing signal will be executed.

void SLNet::RPC4::InvokeSignal | ( | DataStructures::HashIndex | functionIndex,
|  | SLNet::BitStream * | serializedParameters,
|  | Packet * | packet
| ) |  |

protected

static int SLNet::RPC4::LocalCallbackComp | ( | const MessageID & | key,
|  | LocalCallback *const & | data
| ) |  |

static

static int SLNet::RPC4::LocalSlotObjectComp | ( | const LocalSlotObject & | key,
|  | const LocalSlotObject & | data
| ) |  |

static

virtual void SLNet::RPC4::OnAttach | ( | void |  | ) |

protectedvirtual

Called when the interface is attached.

Reimplemented from SLNet::PluginInterface2.

virtual PluginReceiveResult SLNet::RPC4::OnReceive | ( | Packet * | packet | ) |

protectedvirtual

OnReceive is called for every packet.

Parameters

  [in] | packet | the packet that is being returned to the user

Returns
  True to allow the game and other plugins to get this message, false to absorb it

Reimplemented from SLNet::PluginInterface2.

bool SLNet::RPC4::RegisterBlockingFunction | ( | const char * | uniqueID,
|  | void(*)(SLNet::BitStream *userData, SLNet::BitStream *returnData, Packet *packet) | functionPointer
| ) |  |

Same as RegisterFunction, but is called with CallBlocking() instead of Call() and returns a value to the caller.

bool SLNet::RPC4::RegisterFunction | ( | const char * | uniqueID,
|  | void(*)(SLNet::BitStream *userData, Packet *packet) | functionPointer
| ) |  |

Register a function pointer to be callable from a remote system.

Deprecated:
  Use RegisterSlot

The hash of the function name will be stored as an association with the function pointer When a call is made to call this function from the Call() or CallLoopback() function, the function pointer will be invoked with the passed bitStream to Call() and the actual Packet that RakNet got.

See Also
  RegisterPacketCallback()

Parameters

  [in] | uniqueID | Identifier to be associated with functionPointer. If this identifier is already in use, the call will return false.
  [in] | functionPointer | C function pointer to be called

Returns
  True if the hash of uniqueID is not in use, false otherwise.

void SLNet::RPC4::RegisterLocalCallback | ( | const char * | uniqueID,
|  | MessageID | messageId
| ) |  |

Deprecated:
  Use RegisterSlot and invoke on self only when the packet you want arrives When a RakNet Packet with the specified identifier is returned, execute CallLoopback() on a function previously registered with RegisterFunction() For example, you could call "OnClosedConnection" whenever you get ID_DISCONNECTION_NOTIFICATION or ID_CONNECTION_LOST

Parameters

  [in] | uniqueID | Identifier passed to RegisterFunction()
  [in] | messageId | What RakNet packet ID to call on, for example ID_DISCONNECTION_NOTIFICATION or ID_CONNECTION_LOST

void SLNet::RPC4::RegisterSlot | ( | const char * | sharedIdentifier,
|  | void(*)(SLNet::BitStream *userData, Packet *packet) | functionPointer,
|  | int | callPriority
| ) |  |

Register a slot, which is a function pointer to one or more implementations that supports this function signature When a signal occurs, all slots with the same identifier are called.

Parameters

  [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] | 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 SLNet::RPC4::Signal | ( | const char * | sharedIdentifier,
|  | SLNet::BitStream * | bitStream,
|  | PacketPriority | priority,
|  | PacketReliability | reliability,
|  | char | orderingChannel,
|  | const AddressOrGUID | systemIdentifier,
|  | bool | broadcast,
|  | bool | invokeLocal
| ) |  |

Calls zero or more functions identified by sharedIdentifier registered with RegisterSlot()

Parameters

  [in] | sharedIdentifier | parameter of the same name passed to RegisterSlot() on the remote system
  [in] | bitStream | bitStream encoded data to send to the function callback
  [in] | priority | See RakPeerInterface::Send()
  [in] | reliability | See RakPeerInterface::Send()
  [in] | orderingChannel | See RakPeerInterface::Send()
  [in] | systemIdentifier | See RakPeerInterface::Send()
  [in] | broadcast | See RakPeerInterface::Send()
  [in] | invokeLocal | If true, also sends to self.

bool SLNet::RPC4::UnregisterBlockingFunction | ( | const char * | uniqueID | ) |

Same as UnregisterFunction, except for a blocking function.

bool SLNet::RPC4::UnregisterFunction | ( | const char * | uniqueID | ) |

Unregister a function pointer previously registered with RegisterFunction()

Parameters

  [in] | Identifier | originally passed to RegisterFunction()

Returns
  True if the hash of uniqueID was in use, and hence removed. false otherwise.

bool SLNet::RPC4::UnregisterLocalCallback | ( | const char * | uniqueID,
|  | MessageID | messageId
| ) |  |

Remove the association created with RegisterPacketCallback()

Parameters

  [in] | uniqueID | Identifier passed as uniqueID to RegisterLocalCallback()
  [in] | messageId | Identifier passed as messageId to RegisterLocalCallback()

Returns
  True if the combination of uniqueID and messageId was in use, and hence removed

bool SLNet::RPC4::UnregisterSlot | ( | const char * | sharedIdentifier | ) |

Remove the association created with RegisterSlot()

Parameters

  [in] | sharedIdentifier | Identifier passed as sharedIdentifier to RegisterSlot()

#### Member Data Documentation

SLNet::BitStream SLNet::RPC4::blockingReturnValue

protected

Definition at line 224 of file RPC4Plugin.h.

bool SLNet::RPC4::gotBlockingReturnValue

protected

Definition at line 225 of file RPC4Plugin.h.

bool SLNet::RPC4::interruptSignal

protected

Definition at line 232 of file RPC4Plugin.h.

DataStructures::OrderedList<MessageID,LocalCallback*,RPC4::LocalCallbackComp> SLNet::RPC4::localCallbacks

protected

Definition at line 222 of file RPC4Plugin.h.

DataStructures::Hash<SLNet::RakString, LocalSlot*,256, SLNet::RakString::ToInteger> SLNet::RPC4::localSlots

Definition at line 210 of file RPC4Plugin.h.

unsigned int SLNet::RPC4::nextSlotRegistrationCount

protected

Used so slots are called in the order they are registered.

Definition at line 230 of file RPC4Plugin.h.

DataStructures::Hash<SLNet::RakString, void ( * ) (SLNet::BitStream *, SLNet::BitStream *, Packet * ),64, SLNet::RakString::ToInteger> SLNet::RPC4::registeredBlockingFunctions

protected

Definition at line 221 of file RPC4Plugin.h.

DataStructures::Hash<SLNet::RakString, void ( * ) (SLNet::BitStream *, Packet * ),64, SLNet::RakString::ToInteger> SLNet::RPC4::registeredNonblockingFunctions

protected

Definition at line 220 of file RPC4Plugin.h.

struct SLNet::RPC4::LocalCallback

Definition at line 181 of file RPC4Plugin.h.

Class Members
OrderedList< RakString, RakString > | functions |
MessageID | messageId |

struct SLNet::RPC4::LocalSlot

Definition at line 206 of file RPC4Plugin.h.

Class Members
OrderedList< LocalSlotObject, LocalSlotObject, LocalSlotObjectComp > | slotObjects |

struct SLNet::RPC4::LocalSlotObject

Definition at line 190 of file RPC4Plugin.h.

### Public Member Functions

| LocalSlotObject ()
| LocalSlotObject (unsigned int _registrationCount, int _callPriority, void(*_functionPointer)(SLNet::BitStream *userData, Packet *packet))
| ~LocalSlotObject ()

### Public Attributes

unsigned int | registrationCount
int | callPriority
void(* | functionPointer )(SLNet::BitStream *userData, Packet *packet)

#### Constructor & Destructor Documentation

SLNet::RPC4::LocalSlotObject::LocalSlotObject | ( |  | ) |

inline

Definition at line 192 of file RPC4Plugin.h.

SLNet::RPC4::LocalSlotObject::LocalSlotObject | ( | unsigned int | _registrationCount,
|  | int | _callPriority,
|  | void(*)(SLNet::BitStream *userData, Packet *packet) | _functionPointer
| ) |  |

inline

Definition at line 193 of file RPC4Plugin.h.

SLNet::RPC4::LocalSlotObject::~LocalSlotObject | ( |  | ) |

inline

Definition at line 195 of file RPC4Plugin.h.

#### Member Data Documentation

int SLNet::RPC4::LocalSlotObject::callPriority

Definition at line 199 of file RPC4Plugin.h.

void( * SLNet::RPC4::LocalSlotObject::functionPointer)(SLNet::BitStream *userData, Packet *packet)

Definition at line 200 of file RPC4Plugin.h.

unsigned int SLNet::RPC4::LocalSlotObject::registrationCount

Definition at line 198 of file RPC4Plugin.h.

## Enumeration Type Documentation

enum SLNet::RPCErrorCodes

Error codes returned by a remote system as to why an RPC function call cannot execute.

Error code follows packet ID ID_RPC_REMOTE_ERROR, that is packet->data[1]
Name of the function will be appended starting at packet->data[2]

Enumerator:

  RPC_ERROR_FUNCTION_NOT_REGISTERED | Named function was not registered with RegisterFunction(). Check your spelling.

Definition at line 51 of file RPC4Plugin.h.