Page 1 of 1
How to Determine if a User Was Kicked in the USER_EXIT_ROOM Event?
Posted: 26 Aug 2024, 08:48
by ciaoamigos
In the SFS2X.SFSEvent.USER_EXIT_ROOM event, how can I know if the user who is leaving has been kicked out?
Re: How to Determine if a User Was Kicked in the USER_EXIT_ROOM Event?
Posted: 26 Aug 2024, 09:20
by Lapo
Hi,
the information is only available for the User who was kicked. Not for everybody else.
If you need to notify other Users you can do so from server side code.
Cheers
Re: How to Determine if a User Was Kicked in the USER_EXIT_ROOM Event?
Posted: 26 Aug 2024, 09:37
by ciaoamigos
I don't see the SFS EventType.USER BANNED event, or something like that on the server side. Suggestions?
Re: How to Determine if a User Was Kicked in the USER_EXIT_ROOM Event?
Posted: 26 Aug 2024, 10:11
by Lapo
That is correct, could be an idea for a future addition.
In any case, If you control the kicking/banning from server side (i.e. Extensions) you can send an update to the required selection of Users.
Cheers
Re: How to Determine if a User Was Kicked in the USER_EXIT_ROOM Event?
Posted: 26 Aug 2024, 11:19
by ciaoamigos
sorry, another question. Is the person who creates a room the administrator of the room? Can he kick other users?
Re: How to Determine if a User Was Kicked in the USER_EXIT_ROOM Event?
Posted: 26 Aug 2024, 13:51
by Lapo
Hi,
no the User that creates a Room by default is only the owner, not a moderator or admin.
Mods or Admins have the ability to kick and ban Users in any Room.
Users can be made Mods when they log in, by setting their permissions. For instance see here:
https://docs2x.smartfoxserver.com/Exten ... -assistantSee bottom of the article.
Cheers
Re: How to Determine if a User Was Kicked in the USER_EXIT_ROOM Event?
Posted: 27 Aug 2024, 16:00
by ciaoamigos
If I do this, will it work? I intercept the room change event using addEventHandler(SFSEventType.USER_JOIN_ROOM, onUserEnterRoom). I check if the user is the owner of the room. If they are the owner, I update the session with the moderator role using: session.setProperty("$permission", DefaultPermissionProfile.MODERATOR);.
Re: How to Determine if a User Was Kicked in the USER_EXIT_ROOM Event?
Posted: 28 Aug 2024, 06:44
by Lapo
No, this only works at login time.
Also becoming a moderator means you have the power to kick or ban users in any Room.
What you're trying to do seems different and it can be implemented with a bit of server side code. Not much really.
On the client side when a User creates a Room successfully you can add a bunch of "Mod Tools" in the UI so that the client can kick (or ban) other users in the Room.
This in turn will trigger an Extension call to the server where you send the target Room, the User that needs to be moderated, and other required parameters.
The Extension can validate the call by checking that the sender is actually the owner of the Room and use the server side API to kick/ban (or maybe just warn) the other User in that Room.
Hope it helps
Re: How to Determine if a User Was Kicked in the USER_EXIT_ROOM Event?
Posted: 28 Aug 2024, 07:25
by ciaoamigos
Got it, thanks. How can I kick a user out of just one room? When they are banned, they are redirected to the login page and can no longer access the system. Instead, I want to deny access only to that specific room.
Re: How to Determine if a User Was Kicked in the USER_EXIT_ROOM Event?
Posted: 28 Aug 2024, 07:50
by Lapo
For that you will need a specialized logic that keeps track of every banned User and has an associated list of Rooms that cannot be accessed. Also you may need to store this information on disk or database if you need to keep track of the data across multiple server restarts.
Additionally you need to block the ability of Users to join Rooms from client side and instead use a custom Extension request where you can first check your Banning database and see if the client is authorized to join the requested Room.
Blocking client-side joining can be done in the Zone Configurator > PrivilegeManager, where you can disable a number of client side requests. See the docs here:
https://docs2x.smartfoxserver.com/Advan ... ge-managerCheers