Click or drag to resize

SFSEventUSER_COUNT_CHANGE Field

Dispatched when the number of users/players or spectators inside a Room changes.

Namespace:  Sfs2X.Core
Assembly:  SmartFox2X (in SmartFox2X.dll) Version: 1.8.0.0 (1.8.0)
Syntax
C#
public static readonly string USER_COUNT_CHANGE

Field Value

Type: String
Remarks
This event is caused by a JoinRoomRequest request or a LeaveRoomRequest request. The Room must belong to one of the Groups subscribed by the current client; also this event might be fired or not depending on the Room configuration defined upon its creation (see the RoomSettings.Events setting).

The Params object contains the following parameters:

ParameterDescription
room(Room) An object representing the Room in which the users count changed.
uCount(int) The new users count (players in case of Game Room).
sCount(int) The new spectators count (Game Rooms only).
Examples
The following example shows how to handle this event type:
void SomeMethod() {
    sfs.AddEventListener(SFSEvent.USER_COUNT_CHANGE, OnUserCountChange);
}

void OnUserCountChange(BaseEvent evt) {
    Room room = (Room)evt.Params["room"];
    int uCount = (int)evt.Params["uCount"];
    int sCount = (int)evt.Params["sCount"];

    Console.WriteLine("Room: " + room.Name + " contains " + uCount + " users and " + sCount + " spectators");                           // .Net / Unity
    System.Diagnostics.Debug.WriteLine("Room: " + room.Name + " contains " + uCount + " users and " + sCount + " spectators");          // UWP
}
See Also