[Java] leaveRoom doesn't work?

Post here all your questions related with SmartFoxServer Java API

Moderators: Lapo, Bax

Teemu
Posts: 11
Joined: 05 Nov 2008, 12:55
Location: Finland

[Java] leaveRoom doesn't work?

Postby Teemu » 05 Dec 2008, 12:43

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
patso
Posts: 380
Joined: 13 Nov 2006, 13:44
Location: Sofia, Bulgaria

Postby patso » 05 Dec 2008, 16:56

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?
Teemu
Posts: 11
Joined: 05 Nov 2008, 12:55
Location: Finland

Postby Teemu » 08 Dec 2008, 07:15

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.
patso
Posts: 380
Joined: 13 Nov 2006, 13:44
Location: Sofia, Bulgaria

Postby patso » 08 Dec 2008, 07:56

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.
Teemu
Posts: 11
Joined: 05 Nov 2008, 12:55
Location: Finland

Postby Teemu » 08 Dec 2008, 07:59

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.
patso
Posts: 380
Joined: 13 Nov 2006, 13:44
Location: Sofia, Bulgaria

Postby patso » 08 Dec 2008, 08:26

I see. This is really strange. Can you give the debug trace of the SmartFoxClient?
Teemu
Posts: 11
Joined: 05 Nov 2008, 12:55
Location: Finland

Postby Teemu » 08 Dec 2008, 08:57

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?
patso
Posts: 380
Joined: 13 Nov 2006, 13:44
Location: Sofia, Bulgaria

Postby patso » 08 Dec 2008, 09:41

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.
Teemu
Posts: 11
Joined: 05 Nov 2008, 12:55
Location: Finland

Postby Teemu » 08 Dec 2008, 09:50

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.
User avatar
Lapo
Site Admin
Posts: 23027
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 10 Dec 2008, 07:23

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
Lapo
--
gotoAndPlay()
...addicted to flash games
Teemu
Posts: 11
Joined: 05 Nov 2008, 12:55
Location: Finland

Postby Teemu » 10 Dec 2008, 07:24

Yeah, it helped. It works now.

Thanks for your help!

Return to “Java2SE / Android Client API”

Who is online

Users browsing this forum: No registered users and 22 guests