SmartFoxServer 3 C++ Client API 3.1.0-beta
Client API for SmartFoxServer 3
Loading...
Searching...
No Matches
sfs3::requests::QuickJoinOrCreateRoomRequest Class Reference

Joins the first Room matching a given expression, or creates a new one when nothing matches. More...

#include <QuickJoinOrCreateRoomRequest.h>

Inheritance diagram for sfs3::requests::QuickJoinOrCreateRoomRequest:
[legend]

Public Member Functions

 QuickJoinOrCreateRoomRequest (entities::match::MatchExpression exp, std::vector< std::string > groupList, RoomSettings settings, std::shared_ptr< entities::Room > roomToLeave=nullptr)

Detailed Description

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)));
See also
entities::match::MatchExpression
RoomSettings
CreateRoomRequest
event::SFSEvent::ROOM_JOIN
event::SFSEvent::ROOM_JOIN_ERROR
event::SFSEvent::ROOM_ADD
event::SFSEvent::ROOM_CREATION_ERROR

Constructor & Destructor Documentation

◆ QuickJoinOrCreateRoomRequest()

sfs3::requests::QuickJoinOrCreateRoomRequest::QuickJoinOrCreateRoomRequest ( entities::match::MatchExpression exp,
std::vector< std::string > groupList,
RoomSettings settings,
std::shared_ptr< entities::Room > roomToLeave = nullptr )
inline
Parameters
expthe matching expression the server applies while searching a Room to join
groupListthe names of the Groups to search; must not be empty
settingsthe settings describing the Room to create when nothing matches
roomToLeavethe Room the user should leave while joining the found or created one; if nullptr, no Room is left

The documentation for this class was generated from the following files:
  • requests/QuickJoinOrCreateRoomRequest.h
  • requests/QuickJoinOrCreateRoomRequest.cpp