Package | com.smartfoxserver.v2.requests |
Class | public class SpectatorToPlayerRequest |
Inheritance | SpectatorToPlayerRequest com.smartfoxserver.v2.requests.BaseRequest |
If the operation is successful, all the users in the target Room are notified with the spectatorToPlayer event. The operation could fail if no player slots are available in the Game Room at the time of the request; in this case the spectatorToPlayerError event is dispatched to the requester's client.
See also
Method | Defined By | ||
---|---|---|---|
SpectatorToPlayerRequest(targetRoom:Room = null)
Creates a new SpectatorToPlayerRequest instance. | SpectatorToPlayerRequest |
SpectatorToPlayerRequest | () | Constructor |
public function SpectatorToPlayerRequest(targetRoom:Room = null)
Creates a new SpectatorToPlayerRequest instance. The instance must be passed to the SmartFox.send() method for the request to be performed.
ParameterstargetRoom:Room (default = null ) — The Room object corresponding to the Room in which the spectator should be turned to player. If null , the last Room joined by the user is used.
|
See also
private function someMethod():void { sfs.addEventListener(SFSEvent.SPECTATOR_TO_PLAYER, onSpectatorToPlayerSwitch); sfs.addEventListener(SFSEvent.SPECTATOR_TO_PLAYER_ERROR, onSpectatorToPlayerSwitchError); // Switch spectator to player sfs.send(new SpectatorToPlayerRequest()); } private function onSpectatorToPlayerSwitch(evt:SFSEvent):void { trace("Spectator " + evt.params.user + " is now a player"); } private function onSpectatorToPlayerSwitchError(evt:SFSEvent):void { trace("Unable to become a player due to the following error: " + evt.params.errorMessage); }