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

Namespace: Sfs2X.Core
Assembly: SmartFox2X (in SmartFox2X.dll) Version: (1.7.0)


public static readonly string USER_COUNT_CHANGE

Field Value

Type: String


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:

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).


The following example shows how to handle this event type:
 Copy imageCopy
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");          // Windows Universal

See Also