SmartFoxServer Silverlight API
SwitchPlayer Method (roomId)
NamespacesSmartFoxClientAPISmartFoxClientSwitchPlayer(Int32)
Turn a player inside a game room into a spectator.
All players have their player id property set to a value > 0; when a spectator becomes a player, his playerId is set to -1.
If the user joined more than one room, the id of the room where the switch should occurr must be passed to this method.
The switch operation is successful only if at least one spectator slot is available in the room.
Declaration Syntax
C#Visual BasicVisual C++
public void SwitchPlayer(
	int roomId
)
Public Sub SwitchPlayer ( _
	roomId As Integer _
)
public:
void SwitchPlayer(
	int roomId
)
Parameters
roomId (Int32)
the id of the room where the player should be switched to spectator, in case of multi-room join (optional, default value: activeRoomId).
Remarks

Sends:
SFSEvent..::.OnPlayerSwitchedDelegate

Version:
SmartFoxServer Pro

Examples
The following example shows how to turn a player into a spectator.
CopyC#
SFSEvent.onPlayerSwitched += OnPlayerSwitched;

smartFox.SwitchPlayer();

public void OnPlayerSwitched(bool success, int newId, Room room)
{
    if (success)
        Debug.WriteLine("You have been turned into a spectator; your id is " + newId);
    else
        Debug.WriteLine("The attempt to switch from player to spectator failed!");
}
See Also

Assembly: SmartFoxClientAPI_Silverlight (Module: SmartFoxClientAPI_Silverlight) Version: 1.0.0.0 (1.0.0.0)