How to remove a user from a room using an extension?

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

Post Reply
Majiy
Posts: 5
Joined: 06 Jan 2011, 19:29

How to remove a user from a room using an extension?

Post by Majiy »

I´m looking for the "correct" way to remove a user from a room (while joinging another one, in case this matters) using an extension.

I know I can use the removeUser method (in the SFSRoom class), and it works, but it doesn´t seem to fire any of the events I would expect (SFSEvent.ROOM_JOIN or SFSEvent.USER_ENTER_ROOM). So I guess this is not the way this is supposed to be done.

I´ve been looking for a way to send a JoinRoomRequest from an extension, but it doesn´t seem to exist in the Java Api (or I didn´t find it).

Can somebody please give me a nodge to the right direction?
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Post by Lapo »

Always use the SFSApi class.
In this case you will use the leaveRoom() method:
http://docs2x.smartfoxserver.com/api-do ... FSApi.html

Make sure to read the docs abou the API too:
http://docs2x.smartfoxserver.com/Develo ... ension-api
Lapo
--
gotoAndPlay()
...addicted to flash games
Majiy
Posts: 5
Joined: 06 Jan 2011, 19:29

Post by Majiy »

Thank you, it´s working now.

It would be really helpful, especially for SFS beginners, if the JavaDoc for functions that are not meant to be used normally contained a notice like "Attention: you usually do not use this method, use method XXX in the class SFSApi instead".
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Post by Lapo »

Yes, we adopted a different strategy where if a method is not useful it doesn't contain any comment, instead of filling the docs with warnings.

With this said if you read the above article it should clarify the way it works.
Essentially there's just 2 things in the framework: API and data classes.
Any time you need to perform an "action" you go searching for that action in the API (join room, create game, send public message)...
Data classes (Zone, Room, User...) are used as arguments return values by these API methods.
Lapo
--
gotoAndPlay()
...addicted to flash games
Post Reply