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

Creates a new Room in the current Zone More...

#include <CreateRoomRequest.h>

Inherits Sfs2X::Requests::BaseRequest.

Public Member Functions

 CreateRoomRequest (boost::shared_ptr< RoomSettings > settings, bool autoJoin, boost::shared_ptr< Room > roomToLeave)
 Constructor More...
 
 CreateRoomRequest (boost::shared_ptr< RoomSettings > settings, bool autoJoin)
 CreateRoomRequest(boost::shared_ptr<RoomSettings>, bool, boost::shared_ptr<Room>) More...
 
 CreateRoomRequest (boost::shared_ptr< RoomSettings > settings)
 CreateRoomRequest(boost::shared_ptr<RoomSettings>, bool, boost::shared_ptr<Room>) More...
 

Detailed Description

Creates a new Room in the current Zone

Constructor & Destructor Documentation

◆ CreateRoomRequest() [1/3]

Sfs2X::Requests::CreateRoomRequest::CreateRoomRequest ( boost::shared_ptr< RoomSettings settings,
bool  autoJoin,
boost::shared_ptr< Room >  roomToLeave 
)

Constructor

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

Parameters
settingsthe new room settings, see RoomSettings for all the details
autoJoinif true the Room will be joined as soon as it is created
roomToLeaveindicates which Room should be left once the join has succeeded
ptrSmartFox->AddEventListener(SFSEvent::ROOM_ADDED, boost::shared_ptr<EventListenerDelegate> (EventListenerDelegate(CMyClass::OnRoomAdded, (unsigned long long)this));
ptrSmartFox->AddEventListener(SFSEvent::ROOM_CREATION_ERROR, boost::shared_ptr<EventListenerDelegate> (EventListenerDelegate(CMyClass::OnRoomCreationError, (unsigned long long)this));
boost::shared_ptr<Room> theRoom = ptrSmartFox->GetRoomByName("Gonzo's Room");
// Create a new Chat Room
boost::shared_ptr<RoomSettings> settings (new RoomSettings("Animal Chat Room"));
settings->GroupId("ChatGroup");
settings->MaxUsers(40);
boost::shared_ptr<IRequest> request (new CreateRoomRequest(settings));
ptrSmartFox->Send(request);
static void OnRoomAdded(unsigned long long ptrContext, boost::shared_ptr<BaseEvent> ptrEvent);
static void OnRoomCreationError(unsigned long long ptrContext, boost::shared_ptr<BaseEvent>> ptrEvent);
void CMyClass::OnRoomAdded(unsigned long long ptrContext, boost::shared_ptr<BaseEvent> ptrEvent);
{
CMyClass* ptrMyClass = (CMyClass*)ptrContext;
// A new Room was added
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));
}
void CMyClass::OnRoomCreationError(unsigned long long ptrContext, boost::shared_ptr<BaseEvent> ptrEvent);
{
CMyClass* ptrMyClass = (CMyClass*)ptrContext;
// An error occurred while attempting to create the Room
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));
}
See also
RoomSettings, Sfs2X.Requests.Game.SFSGameSettings, Sfs2X.Requests.MMO.MMORoomSettings

◆ CreateRoomRequest() [2/3]

Sfs2X::Requests::CreateRoomRequest::CreateRoomRequest ( boost::shared_ptr< RoomSettings settings,
bool  autoJoin 
)

◆ CreateRoomRequest() [3/3]

Sfs2X::Requests::CreateRoomRequest::CreateRoomRequest ( boost::shared_ptr< RoomSettings settings)