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

Attempt to turn the current User from Player to a Spectator (in a Game Room) More...

#include <PlayerToSpectatorRequest.h>

Inherits Sfs2X::Requests::BaseRequest.

Public Member Functions

 PlayerToSpectatorRequest ()
 PlayerToSpectatorRequest(Room*) More...
 
 PlayerToSpectatorRequest (boost::shared_ptr< Room > targetRoom)
 Constructor More...
 

Detailed Description

Attempt to turn the current User from Player to a Spectator (in a Game Room)

This could fail if no Spectator slots are available in the Room at the time of the request

Constructor & Destructor Documentation

◆ PlayerToSpectatorRequest() [1/2]

Sfs2X::Requests::PlayerToSpectatorRequest::PlayerToSpectatorRequest ( )

PlayerToSpectatorRequest(Room*)

◆ PlayerToSpectatorRequest() [2/2]

Sfs2X::Requests::PlayerToSpectatorRequest::PlayerToSpectatorRequest ( boost::shared_ptr< Room >  targetRoom)

Constructor

Parameters
targetRoomthe Room where the change has to be performed, a null value indicates the last joined Room (default)
ptrSmartFox->AddEventListener(SFSEvent::PLAYER_TO_SPECTATOR, boost::shared_ptr<EventListenerDelegate> (EventListenerDelegate(CMyClass::OnSpectatorOk, (unsigned long long)this));
ptrSmartFox->AddEventListener(SFSEvent::PLAYER_TO_SPECTATOR_ERROR, boost::shared_ptr<EventListenerDelegate> (EventListenerDelegate(CMyClass::OnSpectatorError, (unsigned long long)this));
boost::shared_ptr<IRequest> request (new PlayerToSpectatorRequest());
ptrSmartFox->Send(request);
static void OnSpectatorOk(unsigned long long ptrContext, boost::shared_ptr<BaseEvent> ptrEvent);
static void OnSpectatorError(unsigned long long ptrContext, boost::shared_ptr<BaseEvent> ptrEvent);
void CMyClass::OnSpectatorOk(unsigned long long ptrContext, boost::shared_ptr<BaseEvent> ptrEvent);
{
// Success! I am now a spectator in this Game!
}
void CMyClass::OnSpectatorError(unsigned long long ptrContext, boost::shared_ptr<BaseEvent> ptrEvent);
{
// I was not able to become spectator in the Game
}
See also
Core.SFSEvent.PLAYER_TO_SPECTATOR, Core.SFSEvent.PLAYER_TO_SPECTATOR_ERROR, SpectatorToPlayerRequest