getAllRooms problem

You think you've found a bug? Please report it here.

Moderators: Lapo, Bax

Post Reply
mr_malee
Posts: 29
Joined: 08 Jun 2007, 03:21

getAllRooms problem

Post by mr_malee »

sorry, me again.

having some problems using the getAllRooms() function, it says in the help file that no request is sent to the server, but i think i may need such functionality, here's my problem:

(when i say refresh, i mean userList and all rooms in the currentLobby re-populate)

user A joins
refresh A

user B joins
refresh B
refresh A

user A makes room
refresh A
refresh B
change Lobby to Game
refresh A

user B makes room
refresh B
change Lobby to Game
refresh B

user A leaves Game
refresh A
change Lobby to Chat
refresh A
problem user B's game is not listed

user B leaves Game
refresh B
change Lobby to Chat
refresh B
refresh A
user B has user A's game listed even though it doesn't exist

user A creates Game
refresh A
refresh B
problem, user B now has two user A games listed
change Lobby to Chat
refresh A

any ideas?
mr_malee
Posts: 29
Joined: 08 Jun 2007, 03:21

Post by mr_malee »

also tried (on every refrsh call)

SERVER.getRoomList()

which in turn fires, onRoomListUpdate with all the rooms and supposedly their information. But i get no users in the rooms userList.

i can get the userCount which returns 1, but no userList

why ???

argh, i've spent so long (2 days) on the chat part and its not even that complex and i still cant get it working.
mr_malee
Posts: 29
Joined: 08 Jun 2007, 03:21

Post by mr_malee »

ok so i've decided to give up on trying to get all rooms from the client. I have moved over to the extension and will get it that way

or will i :sigh:

i think there is a bug on the server end, i get this traced out into the console:

[Ljava.lang.Object;@101f287

when i try to access _server.getCurrentZone().getRooms()

which seems like the thing isn't being serialised correctly.

i swear, i must be having the worst experience possible setting up a simple multiplayer game.
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Post by Lapo »

mr_malee,
it seems to me that you aren't familiar with a couple of basic concepts that are repeated all over our documentation.

The local "snapshot" of the rooms kept on the client side is populated with users only for those rooms where the user is joined. If I move to another room I will get the updated user list for the new room and stop receiving events for the previous one (unless I decide to stay in both)

Example:
- I log into Zone A which contains 5 rooms: Lobby,R1, R2, R3, R4
- I get autojoined in the Lobby
- Now my local room list contains all users for the Lobby room. I know nothing about the users in the other rooms.

If you want to listen to events and interact with users from another room you can join that as well. (SmartFoxServer allows multiple room join)

Here -> http://www.smartfoxserver.com/docs/docP ... ecture.htm
we have a detailed article with real life examples of various multiplayer scenarios.
i think there is a bug on the server end, i get this traced out into the console:
[Ljava.lang.Object;@101f287
when i try to access _server.getCurrentZone().getRooms()
The returned object is an array.
You can cycle through it with a for loop just like in Flash :)
Lapo
--
gotoAndPlay()
...addicted to flash games
patso
Posts: 380
Joined: 13 Nov 2006, 13:44
Location: Sofia, Bulgaria

Post by patso »

When you are in game room you don't receive notification when room is created or deleted - thats why you room list is out of date. More info about the various room types and the events they trigger you can read here http://www.smartfoxserver.com/docs/docP ... ecture.htm.
To get up to date room list after you've been in game room you must call getRoomList() (what actually you do).
p.s. Please not that in the onRoomListUpdate event handler you've write the code about the joining in the lobby. So pay special attention about this - especially if you use autoJoin().
mr_malee
Posts: 29
Joined: 08 Jun 2007, 03:21

Post by mr_malee »

Patso - yes i did take into account for that. But it looks like the onRoomListUpdate's roomList doesn't contain userLists. I searched around the board for the answer, seems that the userLists are only available after joining a room

Lapo - thanks, thats very odd, i'm using a "for in" loop over the array, shouldn't really matter if its a [] or {}, and still get nothing. I'll try accessing the list's length and use a for/while loop.

I have read through the docs, many many times. I understand that when a user leaves/ enters a room they receive updates only to that room. The problem i'm having which seems like a bug (to me) is when a user leaves a room, then returns to the lobby only to find the same amount of rooms that were there as when they left, even if there have been rooms created.

so i'm wondering what the use of getAllRooms() is, when that never contains all the rooms. Only ones that were created when the user witnessed them.

And why i can't access userLists on the updateRoomList() function.

I have been looking at all the examples, but the thing is i can't use components. And all the examples use components to add/ remove data.

As of now I am completely stuck.

Thanks for taking the time to read through my problems though :)

EDIT - if a user decides to stay in two rooms, but is joined to only one, does that user exist in both rooms userLists? or just the joined one. If it did then that would solve my problem when another user creates a room from the mainLobby.

I guess that makes little sense, but i'm going out on a limb here

EDIT2 - just tested the array, no go, i get this error:

Code: Select all

response type xml
TypeError: Error #1034: Type Coercion failed: cannot convert "[Ljava.lang.Object;@ffab0a" to Array.
	at Main/::onExtensionResponse()
	at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
	at flash.events::EventDispatcher/dispatchEvent()
	at it.gotoandplay.smartfoxserver.handlers::ExtHandler/handleMessage()
	at it.gotoandplay.smartfoxserver::SmartFoxClient/::xmlReceived()
	at it.gotoandplay.smartfoxserver::SmartFoxClient/::handleMessage()
	at it.gotoandplay.smartfoxserver::SmartFoxClient/::handleSocketData()
Post Reply