SmartFoxServer 2X C++ API
Sfs2X::Requests::JoinRoomRequest Class Reference

Join the current User in a Room. More...

#include <JoinRoomRequest.h>

Inherits Sfs2X::Requests::BaseRequest.

Public Member Functions

 JoinRoomRequest (boost::shared_ptr< Room > id, string pass, boost::shared_ptr< long int > roomIdToLeave, bool asSpectator)
 Constructor More...
 
 JoinRoomRequest (boost::shared_ptr< Room > id, string pass, boost::shared_ptr< long int > roomIdToLeave)
 JoinRoomRequest(boost::shared_ptr<Room>, string, long int, bool) More...
 
 JoinRoomRequest (boost::shared_ptr< Room > id, string pass)
 JoinRoomRequest(boost::shared_ptr<Room>, string, long int, bool) More...
 
 JoinRoomRequest (boost::shared_ptr< Room > id)
 JoinRoomRequest(boost::shared_ptr<Room>, string, long int, bool) More...
 

Detailed Description

Join the current User in a Room.

Constructor & Destructor Documentation

◆ JoinRoomRequest() [1/4]

Sfs2X::Requests::JoinRoomRequest::JoinRoomRequest ( boost::shared_ptr< Room >  id,
string  pass,
boost::shared_ptr< long int >  roomIdToLeave,
bool  asSpectator 
)

Constructor

Parameters
idyou can use the numeric ID of the Room or its name
passneeded only if the Room is password protected
roomIdToLeavethe id of a previously joined Room that you want to leave once joined in the new Room (optional). The default behavior is to leave the previous Room. You can pass a negative ID to avoid leaving any Room
asSpectatorif true it indicates that you want to join the room as spectator (optional, for game Rooms only)
ptrSmartFox->AddEventListener(SFSEvent::ROOM_JOIN, boost::shared_ptr<EventListenerDelegate> (EventListenerDelegate(CMyClass::OnJoinRoom, (unsigned long long)this));
ptrSmartFox->AddEventListener(SFSEvent::ROOM_JOIN_ERROR, boost::shared_ptr<EventListenerDelegate> (EventListenerDelegate(CMyClass::OnJoinRoomError, (unsigned long long)this));
// Send request
boost::shared_ptr<IRequest> request (new JoinRoomRequest("Lobby"));
ptrSmartFox->Send(request);
static void OnJoinRoom(unsigned long long ptrContext, boost::shared_ptr<BaseEvent> ptrEvent);
static void OnJoinRoomError(unsigned long long ptrContext, boost::shared_ptr<BaseEvent> ptrEvent);
void CMyClass::OnJoinRoom(unsigned long long ptrContext, boost::shared_ptr<BaseEvent> ptrEvent);
{
CMyClass* ptrMyClass = (CMyClass*)ptrContext;
// Room joined successfully
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));
// Buddy was removed
}
void CMyClass::OnJoinRoomError(unsigned long long ptrContext, boost::shared_ptr<BaseEvent> ptrEvent);
{
CMyClass* ptrMyClass = (CMyClass*)ptrContext;
boost::shared_ptr<map<string, boost::shared_ptr<void>>> ptrEventParams = ptrEvent->Params();
boost::shared_ptr<void> ptrEventParamValueErrorMessage = (*ptrEventParams)["errorMessage"];
boost::shared_ptr<string> ptrErrorMessage = ((boost::static_pointer_cast<string>)(ptrEventParamValueErrorMessage));
string* message = new string("Join Room failure:" + (*ptrErrorMessage));
}
See also
Core.SFSEvent.ROOM_JOIN, Core.SFSEvent.ROOM_JOIN_ERROR, LeaveRoomRequest

◆ JoinRoomRequest() [2/4]

Sfs2X::Requests::JoinRoomRequest::JoinRoomRequest ( boost::shared_ptr< Room >  id,
string  pass,
boost::shared_ptr< long int >  roomIdToLeave 
)

JoinRoomRequest(boost::shared_ptr<Room>, string, long int, bool)

◆ JoinRoomRequest() [3/4]

Sfs2X::Requests::JoinRoomRequest::JoinRoomRequest ( boost::shared_ptr< Room >  id,
string  pass 
)

JoinRoomRequest(boost::shared_ptr<Room>, string, long int, bool)

◆ JoinRoomRequest() [4/4]

Sfs2X::Requests::JoinRoomRequest::JoinRoomRequest ( boost::shared_ptr< Room >  id)

JoinRoomRequest(boost::shared_ptr<Room>, string, long int, bool)