SmartFoxServer Silverlight API
SwitchSpectator Method (roomId)
Namespaces ► SmartFoxClientAPI ► SmartFoxClient ► SwitchSpectator(Int32)
Turn a spectator inside a game room into a player.
All spectators have their player id property set to -1; when a spectator becomes a player, his player id gets a number > 0, representing the player number. The player id values are assigned by the server, based on the order in which the players joined the room.
If the user joined more than one room, the id of the room where the switch should occur must be passed to this method.
The switch operation is successful only if at least one player slot is available in the room.
Declaration Syntax

C# | Visual Basic | Visual C++

    public void SwitchSpectator(
    	int roomId
    )

    Public Sub SwitchSpectator ( _
    	roomId As Integer _
    )

    public:
    void SwitchSpectator(
    	int roomId
    )

Parameters

roomId (Int32)
  the id of the room where the spectator should be switched, in case of multi-room join (optional, default value: activeRoomId).

Remarks

Sends:
SFSEvent..::.OnSpectatorSwitchedDelegate

Version:
SmartFoxServer Basic / Pro

Examples
The following example shows how to turn a spectator into a player.
CopyC#

    SFSEvent.onSpectatorSwitched += OnSpectatorSwitched;

    smartFox.SwitchSpectator();

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

See Also
IsSpectator()()()
SFSEvent..::.OnSpectatorSwitchedDelegate

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