RakNet  4.0
Public Member Functions | List of all members
RakNet::RelayPlugin Class Reference

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

#include <RelayPlugin.h>

Inheritance diagram for RakNet::RelayPlugin:
RakNet::PluginInterface2

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.
 
virtual PluginReceiveResult OnReceive (Packet *packet)
 
virtual void OnClosedConnection (const SystemAddress &systemAddress, RakNetGUID rakNetGUID, PI2_LostConnectionReason lostConnectionReason)
 
- Public Member Functions inherited from RakNet::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, 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)
 

Detailed Description

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

Member Function Documentation

RelayPluginEnums RakNet::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]keyA 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]guidThe 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 RakNet::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]keyA string to identify out system. Passed to key on AddParticipantOnServer()
[in]relayPluginServerGuidthe RakNetGUID of the system running RelayPlugin
virtual void RakNet::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]systemAddressThe system whose connection was closed
[in]rakNetGuidThe guid of the specified system
[in]lostConnectionReasonHow the connection was closed: manually, connection lost, or notification of disconnection

Reimplemented from RakNet::PluginInterface2.

virtual PluginReceiveResult RakNet::RelayPlugin::OnReceive ( Packet packet)
virtual

OnReceive is called for every packet.

Parameters
[in]packetthe 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 RakNet::PluginInterface2.

void RakNet::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]relayPluginServerGuidthe RakNetGUID of the system running RelayPlugin
[in]destinationGuidThe 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]bitStreamThe data to relay
[in]prioritySee the parameter of the same name in RakPeerInterface::Send()
[in]reliabilitySee the parameter of the same name in RakPeerInterface::Send()
[in]orderingChannelSee the parameter of the same name in RakPeerInterface::Send()
void RakNet::RelayPlugin::SetAcceptAddParticipantRequests ( bool  accept)

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

Parameters
[in]accepttrue to accept, false to not.

The documentation for this class was generated from the following file: