reject a rooom join request question

Post here your questions about the Java client / Android API for SFS2X

Moderators: Lapo, Bax

pantinor
Posts: 17
Joined: 19 Jan 2012, 02:10

reject a rooom join request question

Postby pantinor » 22 Jan 2012, 00:27

What is the technique for rejecting a user from joining a room by doing a query on the uservariable set in the user?

I have a uservariable set and want to reject them from entering if another user in that room already has this variable set.

I dont think I should do this on the client side by iterating thru the room user list since that is empty at the time you submit the join request.

thanks.
pantinor
Posts: 17
Joined: 19 Jan 2012, 02:10

Postby pantinor » 22 Jan 2012, 02:34

I think I figured it out by creating a zone extension for my game to manage that.
pantinor
Posts: 17
Joined: 19 Jan 2012, 02:10

Postby pantinor » 22 Jan 2012, 14:03

Can the room extension use an inner class? I am getting this error. The init of the extension seems ok tho.


22 Jan 2012 08:59:05,768 INFO [main] Extensions - {clue}: ClueGameExtension init


22 Jan 2012 09:00:17,117 WARN [pool-1-thread-1] Extensions - {clue}: Cannot instantiate handler class: java.lang.InstantiationException: org.antinori.multiplayer.ClueGameExtension$JoinRoomEventHandler
pantinor
Posts: 17
Joined: 19 Jan 2012, 02:10

Postby pantinor » 22 Jan 2012, 14:33

Seems to be working better now that i broke out the inner class to its own class.

the only thing i see now is below, but not sure it is causing a problem or not.

22 Jan 2012 09:38:13,402 WARN [pool-1-thread-1] v2.core.SFSEventManager$SFSEventRunner - Error in event handler: java.lang.ClassCastException: com.smartfoxserver.v2.core.SFSEvent cannot be cast to com.smartfoxserver.v2.core.SFSSystemEvent, Event: { USER_JOIN_ROOM, Params: [ZONE, USER, ROOM] } Listener: com.smartfoxserver.v2.entities.managers.SFSExtensionManager@1350ff8
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Postby rjgtav » 22 Jan 2012, 19:11

Hi.

What do you mean by inner class? Can you show the code of your extension?

And yes, the way to filter joinRoom requests is by using an extension and then, from the client, call the extension instead of sending the JoinRoomRequest.
Skills: SFS Pro, SFS2X, AS2.0/AS3.0, Java, HTML5/CSS3/JS, C#
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
pantinor
Posts: 17
Joined: 19 Jan 2012, 02:10

Postby pantinor » 22 Jan 2012, 22:38

oh, it is just a class inside the parent class. (myclass$innerclass)

public class myextension {
class myrequesthandler {
xxx
}
}

I am not using that anymore.

The problem i have now is using the extension request on an extension for a room.

I am getting this below:

com.smartfoxserver.v2.exceptions.SFSExtensionException: User cannot invoke Room extension if he's not joined in that Room. ( User Name: aasdsa, Id: 0, Priv: 0, Sess: 127.0.0.1:53697 ) , [ Room: The Lobby, Id: 1, Group: default, isGame: true ]


Should i put the extension on the zone level instead of the room level, and then check the settings on the rooms at that level?

I am trying to forbid entry to joining the room by doing a lookup on a room variable if it is true or not. I saw the previous post which mentioned i need to use the extension request instead of the join room event handler because that one fired after they are already joined in the room.

thanks.
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Postby rjgtav » 22 Jan 2012, 23:33

Yes, that room join check must go the Zone-Level extension, so you can check for every room.

And yes, send a custom ExtensionRequest from the client (with command like "joinRoom") and then on the Zone-level extension you check if the user is permitted or not to enter that room. If he is, you join him using also the extension, this way you have more control over the situation and don't give much freedom to the client.
Skills: SFS Pro, SFS2X, AS2.0/AS3.0, Java, HTML5/CSS3/JS, C#
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
pantinor
Posts: 17
Joined: 19 Jan 2012, 02:10

Postby pantinor » 26 Jan 2012, 00:54

OK i did not realize i could join them on the extension request as well. That is much better than sending the second room join request after the extension request. will try that, Thanks.

Return to “SFS2X Java / Android API”

Who is online

Users browsing this forum: No registered users and 28 guests