[SOLVED-Not a bug] Possible Bug Related to Joined Rooms

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

Moderators: Lapo, Bax

kaandok
Posts: 9
Joined: 11 Aug 2012, 17:59

[SOLVED-Not a bug] Possible Bug Related to Joined Rooms

Postby kaandok » 20 Aug 2012, 21:01

Hi, there I think I may have spotted a bug on the Java client API.

Here are the steps to reproduce:
1) Client-Side: Listen for ROOM_JOIN events, connect and login to the server
1) Server-Side: Join the user to room X on USER_JOIN_ZONE event
2) Client-Side: On ROOM_JOIN event, log joined rooms list (sfs.getJoinedRooms call), it successfully prints room X
3) Client-Side: Send a public message request as follows: sfs.send(new PublicMessageRequest("i am sending public messages!", null,sfs.getRoomByName("X")));
4) The client api logs an error stating that room X is not joined, whereas it lists room X as joined with sfs.getJoinedRooms call

(sfs is a reference to the SmartFox object)

Can somebody check whether they can reproduce this?

If this is confirmed, are there any workarounds or when can we expect a fix?

Note: This is not a permissions issue, both zone and the room allow sending public messages, finding rooms, etc.
Note 2: This problem is also valid for the ActionScript client, depending on the outcome, I can also open a thread on the related forum.

Best,
Kaan.
Last edited by kaandok on 21 Aug 2012, 11:38, edited 1 time in total.
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Possible Bug Related to Joined Rooms - Latest Version

Postby Lapo » 21 Aug 2012, 08:32

Hi,
a few questions:
1) If the user is joined in Room X you don't need to pass the Room in the PublicMessageRequest. Do you get the same error if you don't?
2) Does it make any difference if the join is done on the client instead of the server?
3) Is Room X in the default Room Group?

Thanks
Lapo
--
gotoAndPlay()
...addicted to flash games
kaandok
Posts: 9
Joined: 11 Aug 2012, 17:59

Re: Possible Bug Related to Joined Rooms - Latest Version

Postby kaandok » 21 Aug 2012, 08:45

Thanks for the reply, here are the answers:

1)That is correct and it works correctly if I don't pass anything, but this workaround only applies to scenario where I want to send a message to the last joined room.
I presume it wouldn't work in a multi-room scenario (where rooms X,Y,Z are joined)

2) Yes if I allow a client side join, it works. But I don't want client-side join requests.

3) Room is is not in the default group but it is among the publicly visible groups.
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Possible Bug Related to Joined Rooms - Latest Version

Postby Lapo » 21 Aug 2012, 09:53

1) Yes, it is correct
2) Okay
3) Under the AdminTool > ZoneConfigurator there is a parameter called Default Room Groups which contains a comma separated list of groups that are auto-subscribed as the User logs into the Zone. Is the Group containing Room X in that list?

As regards a workaround, can you better explain what happens at the server side? From what I understand you are joining the User in multiple Rooms, at login time. Give us a step by step summary.

Thanks
Lapo

--

gotoAndPlay()

...addicted to flash games
kaandok
Posts: 9
Joined: 11 Aug 2012, 17:59

Re: Possible Bug Related to Joined Rooms - Latest Version

Postby kaandok » 21 Aug 2012, 10:28

Answer for your last point: no, the group containing X,Y,Z are not subscribed by default. but the groups they belong are listed in the parameter just above the one you mentioned. i.e. public room groups parameter. so the rooms are publicly available and also client receive ROOM_JOIN event for the room joins that are performed on the server side. besides I couldn't wrap my head around the correlation between a client side error and a server side setting (are the server side settings propagated to clients upon login and enforced on client-side?)

I pretty much outlined the steps to reproduce the problem in my first post, here is it again with multiple rooms
Here are the steps to reproduce:
1) Client-Side: Listen for ROOM_JOIN events, connect and login to the server
1) Server-Side: Join the user to room X,Y,Z on USER_JOIN_ZONE event (this is performed by a server side extension)
2) Client-Side: On ROOM_JOIN event, log joined rooms list (sfs.getJoinedRooms call), it successfully prints room X,Y,Z
3) Client-Side: Send a public message request as follows: sfs.send(new PublicMessageRequest("i am sending public messages!", null,sfs.getRoomByName("X")));
4) The client api logs an error stating that room X is not joined, whereas it lists room X as joined with sfs.getJoinedRooms call

Am I wrong to suspect that this is a bug, presumably the object that is handling sfs.getJoinedRooms and sfs.getRoomByName are not behaving correctly.
Specifically, the handler for sfs.getRoomByName (or the PublicMessageRequest sender, I am not sure) doesn't update its list of rooms joined by the client
with server-side room joins that are propagated to the client via ROOM_JOIN events, whereas the handler for sfs.getJoinedRooms correctly update according to ROOM_JOIN events.
(by handler I am referring to the objects that are handling these calls within the API, not event handlers etc.)

Are these deductions wrong? If I am right, I see no other workaround other than allowing client side join room requests OR custom extension request for sending text messages.
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Possible Bug Related to Joined Rooms - Latest Version

Postby Lapo » 21 Aug 2012, 10:42

Here's the thing:
in response to a successful login, the client receives a list of Rooms based on the DefaultRoomGroups settings in the AdminTool. This populates the RoomManager object on the client.

It is still possible to join any Room by just knowing their name, so you can join "Room X" even if it's not in your local room list. Problem is that the RoomManager doesn't manage Rooms outside the subscribed groups and that is the cause of your problem.

What you should do:

1) Join Room X Group by adding it in the server parameter I mentioned, so it's auto-joined at login time
or
2) Keep a local reference to any of those Rooms that you're joining "freely" without subscribing to their respective Groups

Bottom line:
In general, it's best to subscribe to Room Groups, but there are cases in which you don't want the extra "burden" of getting the whole Group list (if it's huge) and the relative server updates (user counts, global room variable updates, new rooms being added and removed...)

p.s. = more details on this here:
http://docs2x.smartfoxserver.com/Develo ... ogin-phase
Lapo

--

gotoAndPlay()

...addicted to flash games
kaandok
Posts: 9
Joined: 11 Aug 2012, 17:59

Re: Possible Bug Related to Joined Rooms - Latest Version

Postby kaandok » 21 Aug 2012, 11:08

Thanks for the details.

I'd be willing to do 1, if the clients won't receive public message events for other rooms in the group. Does groups do this, I mean do they broadcast public messages in one of group rooms
to every client in the group?

I couldn't understand 2. Doesn't the call sfs.getRoomByName("GroundWar"), get me a reference, After all , the error is not related
to the call sfs.getRoomByName but rather trying to send a public message to the room obtained with it, although it is listed as joine or am I wrong :) ?
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Possible Bug Related to Joined Rooms - Latest Version

Postby Lapo » 21 Aug 2012, 11:31

I'd be willing to do 1, if the clients won't receive public message events for other rooms in the group. Does groups do this, I mean do they broadcast public messages in one of group rooms
to every client in the group?

Nope, the public message is broadcast to all people in the target Room. All others are spared :)

I couldn't understand 2. Doesn't the call sfs.getRoomByName("GroundWar"), get me a reference,

Yes, if the Room is part of any of the default groups. In the case of Room X it isn't so the Room is "unmanaged" and the call to that method will return a null.
After all , the error is not related
to the call sfs.getRoomByName but rather trying to send a public message to the room obtained with it

Yes, correct
although it is listed as joine or am I wrong ?

Sure, every Room you joined is pushed in the joinedRooms list. So you do have a reference.
However that's just a list, there's no getByName() functionality there. So keeping a direct reference (via a variable) is probably easier in order to pass it to the PublicMessageRequest.

Hope it's clear
Lapo

--

gotoAndPlay()

...addicted to flash games
kaandok
Posts: 9
Joined: 11 Aug 2012, 17:59

Re: Possible Bug Related to Joined Rooms - Latest Version

Postby kaandok » 21 Aug 2012, 11:35

Crystal clear, thanks for all the details you have laid out!

Have a great day :)

Return to “SFS2X Java / Android API”

Who is online

Users browsing this forum: No registered users and 18 guests