Page 1 of 1

reject a rooom join request question

Posted: 22 Jan 2012, 00:27
by pantinor
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.

Posted: 22 Jan 2012, 02:34
by pantinor
I think I figured it out by creating a zone extension for my game to manage that.

Posted: 22 Jan 2012, 14:03
by pantinor
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

Posted: 22 Jan 2012, 14:33
by pantinor
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

Posted: 22 Jan 2012, 19:11
by rjgtav
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.

Posted: 22 Jan 2012, 22:38
by pantinor
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.

Posted: 22 Jan 2012, 23:33
by rjgtav
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.

Posted: 26 Jan 2012, 00:54
by pantinor
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.