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

Quickly joins the current user in a public game. More...

#include <QuickJoinGameRequest.h>

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

Public Member Functions

 QuickJoinGameRequest (std::optional< entities::match::MatchExpression > matchExpr, std::vector< std::string > groupIds, std::optional< int32_t > roomIdToLeave=std::nullopt)
 Creates a new QuickJoinGameRequest searching a list of Room Groups.
 QuickJoinGameRequest (std::optional< entities::match::MatchExpression > matchExpr, std::vector< int32_t > roomIds, std::optional< int32_t > roomIdToLeave=std::nullopt)
 Creates a new QuickJoinGameRequest searching a list of Rooms, by id.
 QuickJoinGameRequest (std::optional< entities::match::MatchExpression > matchExpr, const std::vector< std::shared_ptr< entities::Room > > &rooms, std::optional< int32_t > roomIdToLeave=std::nullopt)
 Creates a new QuickJoinGameRequest searching a list of Rooms.

Detailed Description

Quickly joins the current user in a public game.

By providing a matching expression and a list of Rooms or Groups, SmartFoxServer can search for a matching public Game Room and immediately join the user into that Room as a player.

If a game could be found and joined, a ROOM_JOIN event is dispatched to the requester's client, just like an ordinary JoinRoomRequest. If no matching game was found, the client gets a ROOM_JOIN_ERROR event instead.

The matching expression is optional: without it the first Room found in the search scope is good.

auto exp = entities::match::MatchExpression(entities::match::RoomProperties::HAS_FREE_PLAYER_SLOTS,
                                           entities::match::BoolMatch::EQUALS, true);

sfs.send(requests::QuickJoinGameRequest(std::move(exp), { "chessGames" }));
See also
entities::match::MatchExpression
JoinRoomRequest
event::SFSEvent::ROOM_JOIN
event::SFSEvent::ROOM_JOIN_ERROR

Constructor & Destructor Documentation

◆ QuickJoinGameRequest() [1/3]

sfs3::requests::QuickJoinGameRequest::QuickJoinGameRequest ( std::optional< entities::match::MatchExpression > matchExpr,
std::vector< std::string > groupIds,
std::optional< int32_t > roomIdToLeave = std::nullopt )
inline

Creates a new QuickJoinGameRequest searching a list of Room Groups.

Pass it to SmartFox::send for the request to be performed.

Parameters
matchExprA matching expression the server uses to search a Game Room where to join the current user; if empty, the first Room found is good.
groupIdsThe names of the Groups the matching expression is applied to. The list can hold at most 32 names and must not be empty.
roomIdToLeaveThe id of the Room the user should leave when joining the game.
See also
SmartFox::send

◆ QuickJoinGameRequest() [2/3]

sfs3::requests::QuickJoinGameRequest::QuickJoinGameRequest ( std::optional< entities::match::MatchExpression > matchExpr,
std::vector< int32_t > roomIds,
std::optional< int32_t > roomIdToLeave = std::nullopt )
inline

Creates a new QuickJoinGameRequest searching a list of Rooms, by id.

Parameters
matchExprA matching expression the server uses to search a Game Room where to join the current user; if empty, the first Room found is good.
roomIdsThe ids of the Rooms the matching expression is applied to. The list can hold at most 32 ids and must not be empty.
roomIdToLeaveThe id of the Room the user should leave when joining the game.
See also
SmartFox::send

◆ QuickJoinGameRequest() [3/3]

sfs3::requests::QuickJoinGameRequest::QuickJoinGameRequest ( std::optional< entities::match::MatchExpression > matchExpr,
const std::vector< std::shared_ptr< entities::Room > > & rooms,
std::optional< int32_t > roomIdToLeave = std::nullopt )
inline

Creates a new QuickJoinGameRequest searching a list of Rooms.

Only the Room ids travel to the server, so the Rooms are not kept by the request.

Parameters
matchExprA matching expression the server uses to search a Game Room where to join the current user; if empty, the first Room found is good.
roomsThe Rooms the matching expression is applied to. The list can hold at most 32 Rooms and must not be empty.
roomIdToLeaveThe id of the Room the user should leave when joining the game.
See also
SmartFox::send

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