# RakNet::RoomsPlugin Class Reference
[RoomsPlugin]

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

`#include <RoomsPlugin.h>`

Inheritance diagram for RakNet::RoomsPlugin:

List of all members.

## 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)
virtual void | Update (void)
| Update is called every time a packet is checked for .
virtual PluginReceiveResult | OnReceive (Packet *packet)
virtual void | OnClosedConnection (SystemAddress systemAddress, RakNetGUID rakNetGUID, PI2_LostConnectionReason lostConnectionReason)
## 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

## 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]` | systemAddress | The address to add

void RakNet::RoomsPlugin::AddRoomsCallback | ( | RoomsCallback * | _roomsCallback | ) |

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

Parameters:

  `[in]` | _roomsCallback | Class 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]` | oldHandle | The handle previously known by the system
  `[in]` | newHandle | The new handle to use

void RakNet::RoomsPlugin::ExecuteFunc | ( | RoomsPluginFunc * | func,
|  | SystemAddress | remoteAddress |
| ) |  |  |

Execute a function, with a specific address.

Parameters:

  `[in]` | func | Pointer to a base class of RoomsPluginFunc to execute
  `[in]` | remoteAddress | Address to send the command to. The remote system should also be running RoomsPlugin

void RakNet::RoomsPlugin::ExecuteFunc | ( | RoomsPluginFunc * | func | ) |

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

Parameters:

  `[in]` | func | Pointer to a base class of RoomsPluginFunc to execute

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]` | userName | A unique string identifying the user
  `[in]` | roomsParticipantAddress | The address of the user
  `[in]` | guid | The guid of the user
  `[in]` | loginServerAddress | The server adding this user. Use 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]` | userName | A unique string identifying the user
  `[in]` | loginServerAddress | The server removing. Use 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 | ( | 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 PluginInterface2.

virtual void RakNet::RoomsPlugin::OnDetach | ( | void |  | ) | `[virtual]`

Called when the interface is detached

Parameters:

  `[in]` | peer | the instance of RakPeer that is calling Receive

Reimplemented from PluginInterface2.

virtual PluginReceiveResult RakNet::RoomsPlugin::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 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]` | systemAddress | The address to remove

void RakNet::RoomsPlugin::RemoveRoomsCallback | ( | RoomsCallback * | _roomsCallback | ) |

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

Parameters:

  `[in]` | _roomsCallback | Class instance to no longer get callbacks on.

void RakNet::RoomsPlugin::SetOrderingChannel | ( | char | oc | ) |

Ordering channel to send messages on.

Parameters:

  `[in]` | oc | The 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]` | pf | An instance of a profanity filter

void RakNet::RoomsPlugin::SetRoomsCallback | ( | RoomsCallback * | _roomsCallback | ) |

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

Parameters:

  `[in]` | _roomsCallback | Class 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]` | pp | The 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]` | systemAddress | The 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:

- d:/RakNet-3.x/DependentExtensions/Lobby2/Rooms/RoomsPlugin.h