PlayerToSpectatorRequest Class |
Namespace: Sfs2X.Requests
public class PlayerToSpectatorRequest : BaseRequest
Name | Description | |
---|---|---|
PlayerToSpectatorRequest |
See PlayerToSpectatorRequest(Room) constructor.
| |
PlayerToSpectatorRequest(Room) |
Creates a new PlayerToSpectatorRequest instance.
|
void SomeMethod() { sfs.AddEventListener(SFSEvent.PLAYER_TO_SPECTATOR, OnPlayerToSpectatorSwitch); sfs.AddEventListener(SFSEvent.PLAYER_TO_SPECTATOR_ERROR, OnPlayerToSpectatorSwitchError); // Switch player to spectator sfs.Send( new PlayerToSpectatorRequest() ); } void OnPlayerToSpectatorSwitch(BaseEvent evt) { User user = (User)evt.Params["user"]; Console.WriteLine("Player " + user.Name + " is now a spectator"); // .Net / Unity System.Diagnostics.Debug.WriteLine("Player " + user.Name + " is now a spectator"); // UWP } void OnPlayerToSpectatorSwitchError(BaseEvent evt) { Console.WriteLine("Unable to become a spectator due to the following error: " + (string)evt.Params["errorMessage"]); // .Net / Unity System.Diagnostics.Debug.WriteLine("Unable to become a spectator due to the following error: " + (string)evt.Params["errorMessage"]); // UWP }