|
SmartFoxServer 3 C++ Client API 3.1.0-beta
Client API for SmartFoxServer 3
|
Joins the first Room matching a given expression, or creates a new one when nothing matches. More...
#include <QuickJoinOrCreateRoomRequest.h>
Public Member Functions | |
| QuickJoinOrCreateRoomRequest (entities::match::MatchExpression exp, std::vector< std::string > groupList, RoomSettings settings, std::shared_ptr< entities::Room > roomToLeave=nullptr) | |
Joins the first Room matching a given expression, or creates a new one when nothing matches.
The server searches the listed Room Groups for a Room satisfying the matching expression. If it finds one, the current user joins it and a ROOM_JOIN event is dispatched, exactly like an ordinary JoinRoomRequest. If it finds none, a new Room is created from the provided settings: the requester gets a ROOM_ADD event followed by a ROOM_JOIN, because the server always joins the creator into the new Room. Every user subscribed to the new Room's Group gets the ROOM_ADD too.
A failure on either branch comes back as a ROOM_JOIN_ERROR or a ROOM_CREATION_ERROR.
NOTE: Only regular Room creation is allowed (game and non game). Settings carrying an MMOSettings or a GameSettings are not supported.
namespace m = entities::match;
m::MatchExpression exp { "rank", m::NumberMatch::LESS_THAN_OR_EQUAL_TO, 6 };
requests::RoomSettings settings { "pokerTable_12" };
settings.maxUsers = 4;
sfs.send(requests::QuickJoinOrCreateRoomRequest(std::move(exp), { "games" }, std::move(settings)));
|
inline |
| exp | the matching expression the server applies while searching a Room to join |
| groupList | the names of the Groups to search; must not be empty |
| settings | the settings describing the Room to create when nothing matches |
| roomToLeave | the Room the user should leave while joining the found or created one; if nullptr, no Room is left |