SmartFoxServer 2X C++ API
Sfs2X::Requests::Game::QuickJoinGameRequest Class Reference

Quick join a User in a public game. More...

#include <QuickJoinGameRequest.h>

Inherits Sfs2X::Requests::BaseRequest.

Public Member Functions

 QuickJoinGameRequest (boost::shared_ptr< MatchExpression > matchExpression, boost::shared_ptr< vector< string > > whereToSearch)
  QuickJoinGameRequest(boost::shared_ptr<MatchExpression>, boost::shared_ptr<vector<string> >, boost::shared_ptr<Room>) More...
 
 QuickJoinGameRequest (boost::shared_ptr< MatchExpression > matchExpression, boost::shared_ptr< vector< string > > whereToSearch, boost::shared_ptr< Room > roomToLeave)
 Constructor More...
 
 QuickJoinGameRequest (boost::shared_ptr< MatchExpression > matchExpression, boost::shared_ptr< vector< boost::shared_ptr< Room > > > whereToSearch)
  QuickJoinGameRequest(boost::shared_ptr<MatchExpression>, boost::shared_ptr<vector<boost::shared_ptr<Room> > >, boost::shared_ptr<Room>) More...
 
 QuickJoinGameRequest (boost::shared_ptr< MatchExpression > matchExpression, boost::shared_ptr< vector< boost::shared_ptr< Room > > > whereToSearch, boost::shared_ptr< Room > roomToLeave)
 Creates a new QuickJoinGameRequest instance. More...
 

Detailed Description

Quick join a User in a public game.

By providing a MatchExpression and a list of Rooms or Groups the system can search for matching Rooms and immediately teleport the player in the game action.

Constructor & Destructor Documentation

◆ QuickJoinGameRequest() [1/4]

Sfs2X::Requests::Game::QuickJoinGameRequest::QuickJoinGameRequest ( boost::shared_ptr< MatchExpression matchExpression,
boost::shared_ptr< vector< string > >  whereToSearch 
)

◆ QuickJoinGameRequest() [2/4]

Sfs2X::Requests::Game::QuickJoinGameRequest::QuickJoinGameRequest ( boost::shared_ptr< MatchExpression matchExpression,
boost::shared_ptr< vector< string > >  whereToSearch,
boost::shared_ptr< Room >  roomToLeave 
)

Constructor

Parameters
matchExpressiona MatchExpression to filter Rooms
whereToSearchA list of Group names to which the matching expression should be applied. The maximum number of elements in this list is 32.
roomToLeavean optional Room that the User will leave after joining the game
// Add event listener for the Invitation reply event
ptrSmartFox->AddEventListener(SFSEvent::ROOM_JOIN, boost::shared_ptr<EventListenerDelegate> (new EventListenerDelegate(CMyClass::OnRoomJoin, (unsigned long long)this)));
boost::shared_ptr<string> value (new string("Darts"));
boost::shared_ptr<long int> value1 (new long int());
*value1 = 400;
boost::shared_ptr<MatchExpression> exp (new MatchExpression("type", StringMatch::EQUALS, value, MatchExpression::MatchExpressionValueType::MatchExpression_ValueString))->And(new MatchExpression("bestScore", NumberMatch::LESS_THAN, value1, MatchExpression::MatchExpressionValueType::MatchExpression_ValueOther));
// Search the "games" Group for a free public game of Darts with a bestScore variable < 400
boost::shared_ptr<vector<boost::shared_ptr<string>>> whereToSearch (new vector<boost::shared_ptr<string>>);
whereToSearch->push_back("[""games""]");
boost::shared_ptr<IRequest> request (new QuickJoinGameRequest(exp), whereToSearch, ptrSmartFox->MySelf()->LastJoinedRoom());
ptrSmartFox->Send(request);
ptrSmartFox->Send(request);
static void OnRoomJoin(unsigned long long ptrContext, boost::shared_ptr<BaseEvent> ptrEvent);
// Handle responses from invited users
void CMyClass::OnRoomJoin(unsigned long long ptrContext, boost::shared_ptr<BaseEvent> ptrEvent)
{
// Get the pointer to my class
CMyClass* instance = (CMyClass*)ptrContext;
// Successfully joined in Room
boost::shared_ptr<map<string, boost::shared_ptr<void>>> ptrEventParams = ptrEvent->Params();
boost::shared_ptr<void> ptrEventParamValueRoom = (*ptrEventParams)["room"];
boost::shared_ptr<Room> ptrNotifiedRoom = ((boost::static_pointer_cast<Room>))(ptrEventParamValueRoom);
}
See also
Core.SFSEvent.ROOM_JOIN, MatchExpression

◆ QuickJoinGameRequest() [3/4]

Sfs2X::Requests::Game::QuickJoinGameRequest::QuickJoinGameRequest ( boost::shared_ptr< MatchExpression matchExpression,
boost::shared_ptr< vector< boost::shared_ptr< Room > > >  whereToSearch 
)

◆ QuickJoinGameRequest() [4/4]

Sfs2X::Requests::Game::QuickJoinGameRequest::QuickJoinGameRequest ( boost::shared_ptr< MatchExpression matchExpression,
boost::shared_ptr< vector< boost::shared_ptr< Room > > >  whereToSearch,
boost::shared_ptr< Room >  roomToLeave 
)

Creates a new QuickJoinGameRequest instance.

The instance must be passed to the SmartFox.Send method for the request to be performed.

Parameters
matchExpressionA matching expression that the system will use to search a Game Room where to join the current user.
whereToSearchA list of Room objects to which the matching expression should be applied. The maximum number of elements in this list is 32.
roomToLeaveAn object representing the Room that the user should leave when joining the game. Default is null.