Page 1 of 1

[Java] leaveRoom doesn't work?

Posted: 05 Dec 2008, 12:43
by Teemu
Hi!

I have a problem with leaving room. The process goes like this:
- Connect, login and join to room 1 (success)
- I send public message to room 1 (success)
- Join room 2 without leaving room 1 (success)
- send public message to room 2 (success)
- leave room 2 (fails ->)
- after that I don't get onRoomLeft event, and I can still send messages to room 2

Any ideas what could cause this? Is this a bug or again, am I doing something wrong? :)

Thanks,

Teemu

Posted: 05 Dec 2008, 16:56
by patso
I've just made quick test that made all the steps and I didn't have any problem. The second room is left, the event is dispatched and I can't send public messages to the room.

Are you sure you're still in room 1?

Posted: 08 Dec 2008, 07:15
by Teemu
Hmmm, you are right, apparently I do leave from room 1. But when I join to room 2, I use:

sfs.joinRoom(id, "", true);

I thought that when that dontLeave flag is set to true, it should stay also in old room. What am I missing here?

Thanks.

Posted: 08 Dec 2008, 07:56
by patso
Hi,

How do you check if you're in given room?

The sfs.joinRoom(id, "", true); call is correct and if you're in room 1 then you should stay in it.

Posted: 08 Dec 2008, 07:59
by Teemu
I have other client in room 1 and I can see with that other client that user leaves room 1 when he joins room 2.

Posted: 08 Dec 2008, 08:26
by patso
I see. This is really strange. Can you give the debug trace of the SmartFoxClient?

Posted: 08 Dec 2008, 08:57
by Teemu
Ok, I had some faulty code in my application. This room 2 is a dynamic game room, which I first create. Earlier I tried to join that room in onRoomAdded event, because I didn't realize that client joins room automatically after creation.

However, I have exitCurrentRoom set as false in roomProperties, and isGame is set to true. If I put isGame property as false, then the client will stay in room 1 also. Should it work like this?

Posted: 08 Dec 2008, 09:41
by patso
No. You can still be in game room and another room. For example the following code:

Code: Select all

Map<String, Object> params = new HashMap<String, Object>();
params.put("isGame", true);
params.put("exitCurrentRoom", false);
sfs.createRoom("Test Room", 2, params);
will keep the user in the old room. The only difference between regular and game room is that the user is automatically joined into the game room.

Posted: 08 Dec 2008, 09:50
by Teemu
Oh, I found problem by looking SmartFoxClient's source code. There is Boolean exitCurrentRoomBool = (Boolean)roomProperties.get("exitCurrent");

So it's exitCurrent and not exitCurrentRoom as it says in API.

Posted: 10 Dec 2008, 07:23
by Lapo
Teemu: just to make things clear
What is written in the API docs is actually correct. The error is that exitCurrent should be exitCurrentRoom. This way it is "aligned" with the Actionscript 2 and 3 API

We will update the Java API very soon, meanwhile you can use exitCurrent as a workaround.

Hope it helps

Posted: 10 Dec 2008, 07:24
by Teemu
Yeah, it helped. It works now.

Thanks for your help!