SmartFox.joinedRooms problem - lists rooms I already left, and admin tool is correct

Post here your questions about the Flash / Flex / Air API for SFS2X

Moderators: Lapo, Bax

User avatar
Pippoflash
Posts: 135
Joined: 30 Jan 2006, 17:16
Contact:

SmartFox.joinedRooms problem - lists rooms I already left, and admin tool is correct

Postby Pippoflash » 10 Mar 2017, 16:41

Hi,
Navigating through rooms, admin tool reports correctly that I am logged only in 2 rooms. While joinedRooms report also older rooms where I am no longer joined.
Do I miss something?
cheers
-----------------------
www.pippoflash.com
-----------------------
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: SmartFox.joinedRooms problem - lists rooms I already left, and admin tool is correct

Postby Lapo » 10 Mar 2017, 18:37

Hi,
as usual... we need more details:

1- SmartFoxServer version in use
2- Client API version in use
3- Step by step description of how to reproduce

Thanks
Lapo
--
gotoAndPlay()
...addicted to flash games
User avatar
Pippoflash
Posts: 135
Joined: 30 Jan 2006, 17:16
Contact:

Re: SmartFox.joinedRooms problem - lists rooms I already left, and admin tool is correct

Postby Pippoflash » 10 Mar 2017, 20:52

Hi,
just wanted to make sure we didn't miss a setting :)

Client API: SmartFoxServer 2X API Version: 1.1.5
Server: 2.12.2

Here is step by step (from client side perspective, I didn't code server side).

1 - Login, join main lobby
2 - Join game lobby
3 - Join another game lobby
4 - Join another game lobby... etc.

Result: admin tool, correctly sees the user only in room joined in step 4. On client, SmartFox.joinedRooms array, reports the entire list of joined rooms, instead of only the one I am effectively in.

As per documentation:
joinedRooms:Array [read-only]
Returns a list of Room objects representing the Rooms currently joined by the client.

So it should effectively list only last joined room since I am not in the others.

Cheers
-----------------------

www.pippoflash.com

-----------------------
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: SmartFox.joinedRooms problem - lists rooms I already left, and admin tool is correct

Postby Lapo » 11 Mar 2017, 10:00

Client API: SmartFoxServer 2X API Version: 1.1.5

Are you sure that's the version number?
If that's the case you're working with a very old release. The current version of the AS3 API is 1.7.5 I highly recommend to update from here:
http://smartfoxserver.com/download/sfs2x#p=client
Lapo

--

gotoAndPlay()

...addicted to flash games
User avatar
Pippoflash
Posts: 135
Joined: 30 Jan 2006, 17:16
Contact:

Re: SmartFox.joinedRooms problem - lists rooms I already left, and admin tool is correct

Postby Pippoflash » 12 Mar 2017, 19:58

Thank you Lapo, I didn't imagine such an old version is used in the source I received. I will update here if the problem persists.
-----------------------

www.pippoflash.com

-----------------------
User avatar
Pippoflash
Posts: 135
Joined: 30 Jan 2006, 17:16
Contact:

Re: SmartFox.joinedRooms problem - lists rooms I already left, and admin tool is correct

Postby Pippoflash » 28 Mar 2017, 14:24

Problem persists also with latest version of API. I can determine using local logic which rooms I am actually really logged in. But is there something on server side we should change in order to have client list in sync with real rooms I am logged in?
-----------------------

www.pippoflash.com

-----------------------
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: SmartFox.joinedRooms problem - lists rooms I already left, and admin tool is correct

Postby Lapo » 28 Mar 2017, 15:26

I think there's some other issue going on here.

By default when joining a Room will remove you from the previous Room, if it exists.
In other words if you're in Room A and join Room B, you will automatically leave Room A

If you want to join multiple Rooms without leaving the previous one you need to specify it in the JoinRoomRequest.
http://docs2x.smartfoxserver.com/api-do ... quest.html

See the third parameter, you should pass -1

Are you doing this?
Lapo

--

gotoAndPlay()

...addicted to flash games
burnside
Posts: 24
Joined: 11 Mar 2017, 09:30

Re: SmartFox.joinedRooms problem - lists rooms I already left, and admin tool is correct

Postby burnside » 29 Mar 2017, 07:36

Lapo wrote:I think there's some other issue going on here.

By default when joining a Room will remove you from the previous Room, if it exists.
In other words if you're in Room A and join Room B, you will automatically leave Room A

If you want to join multiple Rooms without leaving the previous one you need to specify it in the JoinRoomRequest.
http://docs2x.smartfoxserver.com/api-do ... quest.html

See the third parameter, you should pass -1

Are you doing this?


I think maybe you misunderstood.

Pippoflash wrote:Here is step by step (from client side perspective, I didn't code server side).

1 - Login, join main lobby
2 - Join game lobby
3 - Join another game lobby
4 - Join another game lobby... etc.

Result: admin tool, correctly sees the user only in room joined in step 4. On client, SmartFox.joinedRooms array, reports the entire list of joined rooms, instead of only the one I am effectively in.


Server sees player in: Location_1, Location_1_table_1
Client joinedRooms array sees player in: Location_1, Location_1_table_1, Location_1_table_2, Location_2, Location_2_table_1, etc...

This particular issue is less of a priority now. We wanted to use the joinedRooms to accurately target the Location room for chat messages, but found an alternate way to do it. It seems though like this issue may cause other issues if joinedRooms is used for anything else internally.

Cheers.
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: SmartFox.joinedRooms problem - lists rooms I already left, and admin tool is correct

Postby Lapo » 29 Mar 2017, 08:47

That doesn't sound very plausible. Something else is missing
I would like to see the code used for joining those Rooms.

Thanks
Lapo

--

gotoAndPlay()

...addicted to flash games
burnside
Posts: 24
Joined: 11 Mar 2017, 09:30

Re: SmartFox.joinedRooms problem - lists rooms I already left, and admin tool is correct

Postby burnside » 29 Mar 2017, 18:34

Lapo wrote:That doesn't sound very plausible. Something else is missing
I would like to see the code used for joining those Rooms.


You bet. Here is the core piece, which moves players between tables in-between rounds.

Code: Select all

                // send unjoins
                for (int i = 0; i < tableRoomList.size(); i++) {
                    Room tableRoom = tableRoomList.get(i);
                    List<User> userList = tableRoom.getUserList();
                    int n = userList.size();
                    for (int j = 0; j < n; j++) {
                        User user = userList.get(j);
                        if (user.isPlayer(tableRoom)) {
                            traceOut("movePlayersToTables: send request for player: " + user.getName() + " to leave table: " + tableRoom.getName());
                            sfsApi.leaveRoom(user, tableRoom, true, true);
                        }
                    }
                }
               
                ....state engine code to make sure all removals were successful, then...
               
                // Join all players to their new destinations
                for (int i = 0; i < playerList.size(); i++) {
                    User user = playerList.get(i);

                    int destinationTable = (int) user.getProperty(Enums.USERPROP_table_destination);
                    Room tableRoom = getTableById(destinationTable);

                    traceOut("movePlayersToTables: send request to join player: " + user.getName() + " to table: " + ta$

                    try {
                        //user, room, password, asSpectator, roomToLeave, fire client event, fire server event
                        sfsApi.joinRoom(user, tableRoom, null, false, null, true, true);
                    } catch (SFSJoinRoomException e) {
                        traceOut("movePlayersToTables error in SEND_JOIN: " + e.getMessage());
                    }
                }


The destination table is set based on their performance in the previous round.

On the server side, all works as intended and players reliably move from table to table - verified 100% in the admin tool.

On the client, joinedRooms array gets all confused.
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: SmartFox.joinedRooms problem - lists rooms I already left, and admin tool is correct

Postby Lapo » 30 Mar 2017, 09:16

I've tested by running batches of 10 join requests in 10 different Rooms and then 10 leaves, multiple times, slow, fast, forcing join errors etc... Using different numbers of joins and leaves... Not a single issue. Client side is always consistent with the server.

Considering that AS3 doesn't even use multithreading, it's quite difficult to imagine what might be going wrong.

If you discover anything let us know.
Lapo

--

gotoAndPlay()

...addicted to flash games
burnside
Posts: 24
Joined: 11 Mar 2017, 09:30

Re: SmartFox.joinedRooms problem - lists rooms I already left, and admin tool is correct

Postby burnside » 30 Mar 2017, 16:55

Lapo wrote:I've tested by running batches of 10 join requests in 10 different Rooms and then 10 leaves, multiple times, slow, fast, forcing join errors etc... Using different numbers of joins and leaves... Not a single issue. Client side is always consistent with the server.

Considering that AS3 doesn't even use multithreading, it's quite difficult to imagine what might be going wrong.

If you discover anything let us know.


Are you confirming our code is correct?

And in your tests, did the room memberships overlap? Join room, join room, join room, leave room, join room, leave room, leave room, join room, leave room, leave room?

Or was it all serial? join room, leave room, join room, leave room?

Thanks!
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: SmartFox.joinedRooms problem - lists rooms I already left, and admin tool is correct

Postby Lapo » 31 Mar 2017, 07:24

burnside wrote:Are you confirming our code is correct?

I think so, I don't see anything strange.

And in your tests, did the room memberships overlap? Join room, join room, join room, leave room, join room, leave room, leave room, join room, leave room, leave room?

Or was it all serial? join room, leave room, join room, leave room?


I simulated what I saw in your code: one for loop for joining and another for loop for leaving. Which generate first a batch of joins, then a batch of leave... etc...
Lapo

--

gotoAndPlay()

...addicted to flash games
burnside
Posts: 24
Joined: 11 Mar 2017, 09:30

Re: SmartFox.joinedRooms problem - lists rooms I already left, and admin tool is correct

Postby burnside » 31 Mar 2017, 09:27

Ahhh, ok.

That code was only the code for table management between rounds, not the game room containing the tables nor the game loop itself.

The rest is fairly complex, but all that matters for this issue is the joins and unjoins, which all have client notification = true.

The joins and unjoins the player experiences for a single game would be:

(launch game)
join limbo
(game init)
leave limbo
join Lobby_SomeLocation
(lobby displays games per location, player selects a game)
leave Lobby_SomeLocation
join SomeLocation_1
join SomeLocation_1_Table_1 (as spectator)
(player given option to play next game)
(next game starts)
leave SomeLocation_1_Table_1
join SomeLocation_1_Table_3 (as player)
(plays round 1, round ends)
leave SomeLocation_1_Table_3
join SomeLocation_1_Table_2 (as player)
(plays round 2, round ends)
leave SomeLocation_1_Table_2
join SomeLocation_1_Table_1 (as player)
(plays round 3, round ends)
leave SomeLocation_1_Table_1
join SomeLocation_1_Table_2 (as player)
...etc...etc...
(game ends)
leave SomeLocation_1_Table_2
join SomeLocation_1_Table_1 (as spectator)
(player given option to play next game)

Note how this entire time they remain in SomeLocation_1 so that they can all chat together no matter what table they are at.

This all works, but after a few rounds the joinedRooms array is all gummed up with a list of all the previous tables and if players move around games in the lobby, etc, it'll have those in it too. Seems like when players leave rooms it's not getting removed from the array.

Cheers.
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: SmartFox.joinedRooms problem - lists rooms I already left, and admin tool is correct

Postby Lapo » 31 Mar 2017, 11:10

To simulate a similar scenario I have a client login into a Zone.
The Extension joins it into the Lobby, then starts a Task that every 500ms joins the User in a GameRoom, either as Player or Spectator (random). Then it removes the user from that Room, choses another Room and starts the joining cycle again.

No problems. The client side view is always consistent.

My recommendation is to always call leaveRoom() before joining a User somewhere else. In other words:

1) Remove the client from the Room first ( via leaveRoom() )
2) Then join him in the new Room ( via JoinRoom() )

Why? Because if you use the join default mode, where JoinRoom auto-removes the client from the previous Room, this is going to happen after the new join, resulting in the client being in 3 rooms at once for a small period of time.

Example:
You're joined in Room A and B
If you use the default JoinRoom call to Room C the client will receive a ROOM_JOIN event and if you query the joinedRooms at that moment you will get Room A, Room B and Room C.

Why? Because the server first make sure you have joined Room C before removing you from the previous Room.

Just wanted to mentioned, not that it is the explanation to what you're seeing. But it's worth mentioning.

cheers
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “SFS2X ActionScript 3 API”

Who is online

Users browsing this forum: No registered users and 18 guests