Package | com.smartfoxserver.v2.requests |
Class | public class PlayerToSpectatorRequest |
Inheritance | PlayerToSpectatorRequest com.smartfoxserver.v2.requests.BaseRequest |
If the operation is successful, all the users in the target Room are notified with the playerToSpectator event. The operation could fail if no spectator slots are available in the Game Room at the time of the request; in this case the playerToSpectatorError event is dispatched to the requester's client.
See also
Method | Defined By | ||
---|---|---|---|
PlayerToSpectatorRequest(targetRoom:Room = null)
Creates a new PlayerToSpectatorRequest instance. | PlayerToSpectatorRequest |
PlayerToSpectatorRequest | () | Constructor |
public function PlayerToSpectatorRequest(targetRoom:Room = null)
Creates a new PlayerToSpectatorRequest 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 player should be turned to spectator. If null , the last Room joined by the user is used.
|
See also
private function someMethod():void { sfs.addEventListener(SFSEvent.PLAYER_TO_SPECTATOR, onPlayerToSpectatorSwitch); sfs.addEventListener(SFSEvent.PLAYER_TO_SPECTATOR_ERROR, onPlayerToSpectatorSwitchError); // Switch player to spectator sfs.send(new PlayerToSpectatorRequest()); } private function onPlayerToSpectatorSwitch(evt:SFSEvent):void { trace("Player " + evt.params.user + " is now a spectator"); } private function onPlayerToSpectatorSwitchError(evt:SFSEvent):void { trace("Unable to become a spectator due to the following error: " + evt.params.errorMessage); }