RakNet  4.0
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
RakNet::RoomsPlugin Class Reference

Used to create rooms for players where they can matchmake. More...

#include <RoomsPlugin.h>

Inheritance diagram for RakNet::RoomsPlugin:
RakNet::PluginInterface2

Public Member Functions

void SetOrderingChannel (char oc)
 Ordering channel to send messages on.
 
void SetSendPriority (PacketPriority pp)
 Send priority to send messages on.
 
void SetRoomsCallback (RoomsCallback *_roomsCallback)
 Set the callback to get notification and ExecuteFunc() results.
 
void AddRoomsCallback (RoomsCallback *_roomsCallback)
 Add a callback to get notification and ExecuteFunc() results.
 
void RemoveRoomsCallback (RoomsCallback *_roomsCallback)
 Remove a callback to get notification and ExecuteFunc() results.
 
void ExecuteFunc (RoomsPluginFunc *func)
 Execute a function, using the system address passed to SetServerAddress();.
 
void ExecuteFunc (RoomsPluginFunc *func, SystemAddress remoteAddress)
 Execute a function, with a specific address.
 
void SetServerAddress (SystemAddress systemAddress)
 Sets the remote server address that is running RoomsPlugin. Send calls will go to this function.
 
bool LoginRoomsParticipant (RakNet::RakString userName, SystemAddress roomsParticipantAddress, RakNetGUID guid, SystemAddress loginServerAddress)
 Add a participant to the system.
 
bool LogoffRoomsParticipant (RakNet::RakString userName, SystemAddress loginServerAddress)
 Removes a participant from the system.
 
void ClearRoomMembers ()
 Clear all users.
 
void ChangeHandle (RakNet::RakString oldHandle, RakNet::RakString newHandle)
 Change the handle a user.
 
void AddLoginServerAddress (SystemAddress systemAddress)
 Add a SystemAddress to a list that will be checked when LoginRoomsParticipant() and LogoffRoomsParticipant() is called.
 
void RemoveLoginServerAddress (SystemAddress systemAddress)
 Remove a SystemAddress from a list that will be checked when LoginRoomsParticipant() and LogoffRoomsParticipant() is called.
 
void ClearLoginServerAdddresses (void)
 Remove all addresses added with AddLoginServerAddress()
 
void SetProfanityFilter (ProfanityFilter *pf)
 Sets the profanity filter for the system to use (optional)
 
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 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 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)
 

Static Public Member Functions

static void SerializeLogin (RakNet::RakString userName, SystemAddress userAddress, RakNetGUID guid, RakNet::BitStream *bs)
 Used for Lobby2. Serializes the same data that the plugin itself uses to login.
 
static void SerializeLogoff (RakNet::RakString userName, RakNet::BitStream *bs)
 Used for Lobby2. Serializes the same data that the plugin itself uses to logoff.
 
static void SerializeChangeHandle (RakNet::RakString oldHandle, RakNet::RakString newHandle, RakNet::BitStream *bs)
 Used for Lobby2. Serializes the same data that the plugin itself uses to change handles.
 

Public Attributes

AllGamesRoomsContainer roomsContainer
 Only used on the server. Locally perform any desired functions, such as logging off players.
 

Detailed Description

Used to create rooms for players where they can matchmake.

A room is similar to the rooms you see in other lobby systems, where groups of players can join together in order to start a game match
Each player can be in at most one room.
Each player name must be unique.
Each room has one moderator, which can perform operations on the room such as kicking out members.
This plugin networks the AllGamesRoomsContainer class, which performs the actual functionality.

To use as a client:

  1. Connect to the server and attach the plugin as normal.
  2. Call SetServerAddress to tell the system where the server is.
  3. Call RoomsPlugin::SetRoomsCallback() with a pointer to a callback structure
  4. Fill in the input parameters of the desired structure(s)
  5. Call RoomsPlugin::ExecuteFunc with a pointer to the structure.
  6. Process the callback, which will contain the original input parameters, plus the new output parameters. All structures contain resultCode, which indicates if the operation was successful (REC_SUCCESS) or not (Anything else)


To use as a server:

  1. Start RakNet as usual, accepting connections and attaching the plugin
  2. Call RoomsPlugin::SetProfanityFilter() with the ProfanityFilter class, if desired
  3. Call RoomsPlugin::AddTitle() for each title (game) you want to support
  4. If you want other systems to be able to call RoomsPlugin::LoginRoomsParticipant(), call RoomsPlugin::AddLoginServerAddress() with the addresses of those systems
  5. As users go online, call RoomsPlugin::LoginRoomsParticipant(). Login and Logoff is up to you to implement (or rely on other systems, such as Lobby2)
  6. As users go offline, call RoomsPlugin::LogoffRoomsParticipant();
See Also
AllGamesRoomsContainer
TeamManager TeamManager performs some of the same functions as RoomsPlugin in a more flexible way

Member Function Documentation

void RakNet::RoomsPlugin::AddLoginServerAddress ( SystemAddress  systemAddress)

Add a SystemAddress to a list that will be checked when LoginRoomsParticipant() and LogoffRoomsParticipant() is called.

Parameters
[in]systemAddressThe address to add
void RakNet::RoomsPlugin::AddRoomsCallback ( RoomsCallback *  _roomsCallback)

Add a callback to get notification and ExecuteFunc() results.

Parameters
[in]_roomsCallbackClass instance to get callbacks on. Should remain a valid pointer for the duration of the plugin execution.
void RakNet::RoomsPlugin::ChangeHandle ( RakNet::RakString  oldHandle,
RakNet::RakString  newHandle 
)

Change the handle a user.

Parameters
[in]oldHandleThe handle previously known by the system
[in]newHandleThe new handle to use
void RakNet::RoomsPlugin::ExecuteFunc ( RoomsPluginFunc func)

Execute a function, using the system address passed to SetServerAddress();.

Parameters
[in]funcPointer to a base class of RoomsPluginFunc to execute
void RakNet::RoomsPlugin::ExecuteFunc ( RoomsPluginFunc func,
SystemAddress  remoteAddress 
)

Execute a function, with a specific address.

Parameters
[in]funcPointer to a base class of RoomsPluginFunc to execute
[in]remoteAddressAddress to send the command to. The remote system should also be running RoomsPlugin
bool RakNet::RoomsPlugin::LoginRoomsParticipant ( RakNet::RakString  userName,
SystemAddress  roomsParticipantAddress,
RakNetGUID  guid,
SystemAddress  loginServerAddress 
)

Add a participant to the system.

Only participants can perform operations

Parameters
[in]userNameA unique string identifying the user
[in]roomsParticipantAddressThe address of the user
[in]guidThe guid of the user
[in]loginServerAddressThe server adding this user. Use RakNet::UNASSIGNED_SYSTEM_ADDRESS for not applicable. Otherwise, the address must previously have been added using AddLoginServerAddress() or the function will fail.
bool RakNet::RoomsPlugin::LogoffRoomsParticipant ( RakNet::RakString  userName,
SystemAddress  loginServerAddress 
)

Removes a participant from the system.

Parameters
[in]userNameA unique string identifying the user
[in]loginServerAddressThe server removing. Use RakNet::UNASSIGNED_SYSTEM_ADDRESS for not applicable. Otherwise, the address must previously have been added using AddLoginServerAddress() or the function will fail.
virtual void RakNet::RoomsPlugin::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::RoomsPlugin::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::RoomsPlugin::RemoveLoginServerAddress ( SystemAddress  systemAddress)

Remove a SystemAddress from a list that will be checked when LoginRoomsParticipant() and LogoffRoomsParticipant() is called.

Parameters
[in]systemAddressThe address to remove
void RakNet::RoomsPlugin::RemoveRoomsCallback ( RoomsCallback *  _roomsCallback)

Remove a callback to get notification and ExecuteFunc() results.

Parameters
[in]_roomsCallbackClass instance to no longer get callbacks on.
void RakNet::RoomsPlugin::SetOrderingChannel ( char  oc)

Ordering channel to send messages on.

Parameters
[in]ocThe ordering channel
void RakNet::RoomsPlugin::SetProfanityFilter ( ProfanityFilter *  pf)

Sets the profanity filter for the system to use (optional)

If set, room names and player handles will be checked for profanity. Room invitations and other messages are not checked.

Parameters
[in]pfAn instance of a profanity filter
void RakNet::RoomsPlugin::SetRoomsCallback ( RoomsCallback *  _roomsCallback)

Set the callback to get notification and ExecuteFunc() results.

Parameters
[in]_roomsCallbackClass instance to get callbacks on. Should remain a valid pointer for the duration of the plugin execution.
void RakNet::RoomsPlugin::SetSendPriority ( PacketPriority  pp)

Send priority to send messages on.

Parameters
[in]ppThe packet priority
void RakNet::RoomsPlugin::SetServerAddress ( SystemAddress  systemAddress)

Sets the remote server address that is running RoomsPlugin. Send calls will go to this function.

Parameters
[in]systemAddressThe remote system, which should be connected while calling client functions

Member Data Documentation

AllGamesRoomsContainer RakNet::RoomsPlugin::roomsContainer

Only used on the server. Locally perform any desired functions, such as logging off players.

Note
Use AllGamesRoomsContainer::AddTitle() to add titles

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