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
RelayPlugin
Plugins

A simple class to relay messages from one system to another through an intermediary. More...

## Classes

class | SLNet::RelayPlugin
| A simple class to relay messages from one system to another, identifying remote systems by a string. More...
struct | SLNet::RelayPlugin::RP_Group
struct | SLNet::RelayPlugin::StrAndGuid
struct | SLNet::RelayPlugin::StrAndGuidAndRoom

## Detailed Description

A simple class to relay messages from one system to another through an intermediary.

## Class Documentation

class SLNet::RelayPlugin

A simple class to relay messages from one system to another, identifying remote systems by a string.

Definition at line 67 of file RelayPlugin.h.

Inheritance diagram for SLNet::RelayPlugin:

### Public Member Functions

| RelayPlugin ()
| Constructor.
virtual | ~RelayPlugin ()
| Destructor.
RelayPluginEnums | AddParticipantOnServer (const RakString &key, const RakNetGUID &guid)
| Forward messages from any system, to the system specified by the combination of key and guid. The sending system only needs to know the key.
void | RemoveParticipantOnServer (const RakNetGUID &guid)
| Remove a chat participant.
void | SetAcceptAddParticipantRequests (bool accept)
| If true, then if the client calls AddParticipantRequestFromClient(), the server will call AddParticipantOnServer() automatically Defaults to false.
void | AddParticipantRequestFromClient (const RakString &key, const RakNetGUID &relayPluginServerGuid)
| Request from the client for the server to call AddParticipantOnServer()
void | RemoveParticipantRequestFromClient (const RakNetGUID &relayPluginServerGuid)
| Remove yourself as a participant.
void | SendToParticipant (const RakNetGUID &relayPluginServerGuid, const RakString &destinationGuid, BitStream *bitStream, PacketPriority priority, PacketReliability reliability, char orderingChannel)
| Request that the server relay bitStream to the system designated by key.
void | SendGroupMessage (const RakNetGUID &relayPluginServerGuid, BitStream *bitStream, PacketPriority priority, PacketReliability reliability, char orderingChannel)
void | JoinGroupRequest (const RakNetGUID &relayPluginServerGuid, RakString groupName)
void | LeaveGroup (const RakNetGUID &relayPluginServerGuid)
void | GetGroupList (const RakNetGUID &relayPluginServerGuid)
virtual PluginReceiveResult | OnReceive (Packet *packet)
virtual void | OnClosedConnection (const SystemAddress &systemAddress, RakNetGUID rakNetGUID, PI2_LostConnectionReason lostConnectionReason)
Public Member Functions inherited from SLNet::PluginInterface2
| PluginInterface2 ()
virtual | ~PluginInterface2 ()
virtual void | OnAttach (void)
| Called when the interface is attached.
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, 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)

### Protected Member Functions

RelayPlugin::RP_Group * | JoinGroup (RakNetGUID userGuid, RakString roomName)
RelayPlugin::RP_Group * | JoinGroup (RP_Group *room, StrAndGuidAndRoom **strAndGuidSender)
void | LeaveGroup (StrAndGuidAndRoom **strAndGuidSender)
void | NotifyUsersInRoom (RP_Group *room, int msg, const RakString &message)
void | SendMessageToRoom (StrAndGuidAndRoom **strAndGuidSender, BitStream *message)
void | SendChatRoomsList (RakNetGUID target)
void | OnGroupMessageFromClient (Packet *packet)
void | OnJoinGroupRequestFromClient (Packet *packet)
void | OnLeaveGroupRequestFromClient (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 < RakString, StrAndGuidAndRoom *, 8096, SLNet::RakString::ToInteger > | strToGuidHash
DataStructures::Hash < RakNetGUID, StrAndGuidAndRoom *, 8096, SLNet::RakNetGUID::ToUint32 > | guidToStrHash
DataStructures::List< RP_Group * > | chatRooms
bool | acceptAddParticipantRequests
Protected Attributes inherited from SLNet::PluginInterface2
RakPeerInterface * | rakPeerInterface
TCPInterface * | tcpInterface

#### Constructor & Destructor Documentation

SLNet::RelayPlugin::RelayPlugin | ( |  | ) |

Constructor.

virtual SLNet::RelayPlugin::~RelayPlugin | ( |  | ) |

virtual

Destructor.

#### Member Function Documentation

RelayPluginEnums SLNet::RelayPlugin::AddParticipantOnServer | ( | const RakString & | key,
|  | const RakNetGUID & | guid
| ) |  |

Forward messages from any system, to the system specified by the combination of key and guid. The sending system only needs to know the key.

Parameters

  [in] | key | A string to identify the target's RakNetGUID. This is so the sending system does not need to know the RakNetGUID of the target system. The key should be unique among all guids added. If the key is not unique, only one system will be sent to (at random).
  [in] | guid | The RakNetGuid of the system to send to. If this system disconnects, it is removed from the internal hash

Returns
  RPE_ADD_CLIENT_TARGET_NOT_CONNECTED, RPE_ADD_CLIENT_NAME_ALREADY_IN_USE, or RPE_ADD_CLIENT_OK

void SLNet::RelayPlugin::AddParticipantRequestFromClient | ( | const RakString & | key,
|  | const RakNetGUID & | relayPluginServerGuid
| ) |  |

Request from the client for the server to call AddParticipantOnServer()

Precondition
  The server must have called SetAcceptAddParticipantRequests(true) or the request will be ignored

Parameters

  [in] | key | A string to identify out system. Passed to key on AddParticipantOnServer()
  [in] | relayPluginServerGuid | the RakNetGUID of the system running RelayPlugin

void SLNet::RelayPlugin::GetGroupList | ( | const RakNetGUID & | relayPluginServerGuid | ) |

RelayPlugin::RP_Group* SLNet::RelayPlugin::JoinGroup | ( | RakNetGUID | userGuid,
|  | RakString | roomName
| ) |  |

protected

RelayPlugin::RP_Group* SLNet::RelayPlugin::JoinGroup | ( | RP_Group * | room,
|  | StrAndGuidAndRoom ** | strAndGuidSender
| ) |  |

protected

void SLNet::RelayPlugin::JoinGroupRequest | ( | const RakNetGUID & | relayPluginServerGuid,
|  | RakString | groupName
| ) |  |

void SLNet::RelayPlugin::LeaveGroup | ( | const RakNetGUID & | relayPluginServerGuid | ) |

void SLNet::RelayPlugin::LeaveGroup | ( | StrAndGuidAndRoom ** | strAndGuidSender | ) |

protected

void SLNet::RelayPlugin::NotifyUsersInRoom | ( | RP_Group * | room,
|  | int | msg,
|  | const RakString & | message
| ) |  |

protected

virtual void SLNet::RelayPlugin::OnClosedConnection | ( | const SystemAddress & | systemAddress,
|  | RakNetGUID | rakNetGUID,
|  | PI2_LostConnectionReason | lostConnectionReason
| ) |  |

virtual

Called when a connection is dropped because the user called RakPeer::CloseConnection() for a particular system

Parameters

  [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 SLNet::PluginInterface2.

void SLNet::RelayPlugin::OnGroupMessageFromClient | ( | Packet * | packet | ) |

protected

void SLNet::RelayPlugin::OnJoinGroupRequestFromClient | ( | Packet * | packet | ) |

protected

void SLNet::RelayPlugin::OnLeaveGroupRequestFromClient | ( | Packet * | packet | ) |

protected

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

virtual

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.

void SLNet::RelayPlugin::RemoveParticipantOnServer | ( | const RakNetGUID & | guid | ) |

Remove a chat participant.

void SLNet::RelayPlugin::RemoveParticipantRequestFromClient | ( | const RakNetGUID & | relayPluginServerGuid | ) |

Remove yourself as a participant.

void SLNet::RelayPlugin::SendChatRoomsList | ( | RakNetGUID | target | ) |

protected

void SLNet::RelayPlugin::SendGroupMessage | ( | const RakNetGUID & | relayPluginServerGuid,
|  | BitStream * | bitStream,
|  | PacketPriority | priority,
|  | PacketReliability | reliability,
|  | char | orderingChannel
| ) |  |

void SLNet::RelayPlugin::SendMessageToRoom | ( | StrAndGuidAndRoom ** | strAndGuidSender,
|  | BitStream * | message
| ) |  |

protected

void SLNet::RelayPlugin::SendToParticipant | ( | const RakNetGUID & | relayPluginServerGuid,
|  | const RakString & | destinationGuid,
|  | BitStream * | bitStream,
|  | PacketPriority | priority,
|  | PacketReliability | reliability,
|  | char | orderingChannel
| ) |  |

Request that the server relay bitStream to the system designated by key.

Parameters

  [in] | relayPluginServerGuid | the RakNetGUID of the system running RelayPlugin
  [in] | destinationGuid | The key value passed to AddParticipant() earlier on the server. If this was not done, the server will not relay the message (it will be silently discarded).
  [in] | bitStream | The data to relay
  [in] | priority | See the parameter of the same name in RakPeerInterface::Send()
  [in] | reliability | See the parameter of the same name in RakPeerInterface::Send()
  [in] | orderingChannel | See the parameter of the same name in RakPeerInterface::Send()

void SLNet::RelayPlugin::SetAcceptAddParticipantRequests | ( | bool | accept | ) |

If true, then if the client calls AddParticipantRequestFromClient(), the server will call AddParticipantOnServer() automatically Defaults to false.

Parameters

  [in] | accept | true to accept, false to not.

#### Member Data Documentation

bool SLNet::RelayPlugin::acceptAddParticipantRequests

protected

Definition at line 155 of file RelayPlugin.h.

DataStructures::List<RP_Group*> SLNet::RelayPlugin::chatRooms

protected

Definition at line 154 of file RelayPlugin.h.

DataStructures::Hash<RakNetGUID, StrAndGuidAndRoom*, 8096, SLNet::RakNetGUID::ToUint32> SLNet::RelayPlugin::guidToStrHash

protected

Definition at line 153 of file RelayPlugin.h.

DataStructures::Hash<RakString, StrAndGuidAndRoom*, 8096, SLNet::RakString::ToInteger> SLNet::RelayPlugin::strToGuidHash

protected

Definition at line 152 of file RelayPlugin.h.

struct SLNet::RelayPlugin::RP_Group

Definition at line 134 of file RelayPlugin.h.

Class Members
RakString | roomName |
List< StrAndGuid > | usersInRoom |

struct SLNet::RelayPlugin::StrAndGuid

Definition at line 128 of file RelayPlugin.h.

Class Members
RakNetGUID | guid |
RakString | str |

struct SLNet::RelayPlugin::StrAndGuidAndRoom

Definition at line 121 of file RelayPlugin.h.

Class Members
RakString | currentRoom |
RakNetGUID | guid |
RakString | str |