getUserList returns an empty array when there is a user

Need help with SmartFoxServer? You didn't find an answer in our documentation? Please, post your questions here!

Moderators: Lapo, Bax

wylkyn
Posts: 18
Joined: 26 May 2010, 16:19

Post by wylkyn »

The following is what I was able to trace in the two separate debug textfields of the two users. Here is the trace from Jack's point of view that shows the userlist after Jack logs in, then after Steve logs in:
userlist = ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,[object User]
User list(32):
list item #31: [object User]
Jack
userlist = ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,[object User]
User list(33):
list item #32: [object User]
Steve
And here is the userlist that is returned to Steve after he logs in:
userlist = ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,[object User],[object User]
User list(33):
list item #32: [object User]
Steve
list item #31: [object User]
Jack
As you can see, Jack disappears from his own returned userlist once Steve logs in, but Steve receives a userlist that has both users in it. Both arrays contain 33 items, but for some reason the second to last slot in Jack's array that used to contain his User object is now empty just for him.
wylkyn
Posts: 18
Joined: 26 May 2010, 16:19

Post by wylkyn »

I'm going to keep posting my comments about my process of trying to find the answer to this in the hopes that it will spark some sort of idea for someone...anyone...as to what the problem might be.

This morning I tried just taking out my user list display altogether to see if I got any problems. Both my users seemed to join the room just fine, but when I tried to have one of them chat using the SFSBits ChatBox, I got that old Error #1009 specifically from the ChatBox trying to deal with a null object. And when I had one of the users drop out of the room, the same 1088 error came up. So it doesn't appear to have anything to do with my user list code.
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Post by Lapo »

Thanks for your reply. I looked for an example of the SimpleChat for AS3 but I can only seem to find one for AS2. Is there a download link?
The AS3 examples are done both in Flex and Flash.
The Simple Chat is done in Flex. There is absolutely no difference in the code for Flex or Flash as regards SmartFoxServer usage.
The code is always Actionscript 3 and the logic doesn't change so you can learn the concepts from those sources and apply them your Flash code.

Some of the advanced examples in AS3 were added recently. See here:
http://forums.smartfoxserver.com/viewtopic.php?t=6669
Lapo
--
gotoAndPlay()
...addicted to flash games
wylkyn
Posts: 18
Joined: 26 May 2010, 16:19

Post by wylkyn »

Lapo wrote:The AS3 examples are done both in Flex and Flash.
I can't believe that after all my posts about the problem I am pursuing, this is all you give me in response. I'm well aware that this could be something I am doing wrong, but I am completely stumped. I have wasted at least a couple of weeks of our company's time searching through scattered documentation, poorly coded examples, and the forums, trying in vain to figure out why I am apparently getting two different userlists back for the same server call - room.getUserList. The userlist isn't the problem, however, because when I take the userlist out altogether, there are still errors. I am completely at my wits end, and I'm about to recommend to my company that we forget about using Smartfox for our games, as I can't get it to work, and I can't get the customer support I need to deal with this problem.

Seriously - telling me to look at the examples is not helpful at all. That is what I have been doing. Please advise me how I can get some real help with my problem.
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Post by Lapo »

Your attitude baffles me.
Insults are unlikely to get you any better/quicker assistance.

Let me set things straight: you get the full product, examples and documentation plus an active support board filled with helpful topics. Your questions are answered within 24 hours. And the cost is zero :)

Also we have a very precise policy in this board: provide a precise description of your issue and how to replicate it and you'll get help faster. Rules here: http://forums.smartfoxserver.com/viewtopic.php?t=3307

If you post complaints about something not working and don't provide a meaningful description of what you are doing it's likely you will get little to no help. At least in the free form.

(FYI we also provide paid dedicated support, which is faster and since it's paid we usually get very detailed reports from the start :D But when it's free ... who cares right? The support guys will figure it out.)

As regards pointing you to the working examples, the reason is very simple: they work out of the box and they are meant as "quick lessons".
Lots of people skip the whole documentation and most of the examples, which is at times understandable... the world's running fast, who has time to check some working examples, right?

The idea is that we provide simple working examples that show how to use almost each and every feature of the framework. Since learning from "real stuff" is faster and more enjoyable than reading boring docs we hope that this, at least, will help those with little time to study how things work.
Lapo
--
gotoAndPlay()
...addicted to flash games
wylkyn
Posts: 18
Joined: 26 May 2010, 16:19

Post by wylkyn »

I don't understand how I have insulted you. I'm not quite sure why you are being so defensive. As for full information on my problem, I don't know what else I can provide for you that I already haven't other than the code itself. You want to be able to replicate our problem? You will need to interact with our custom login and game extensions running on our server. How exactly do I explain how to recreate that error on your end?

Here is what I have tried to tell you throughout all my posts in this thread:
-We are running the latest version of your server software.
-The interaction works fine with the code for our iPhone client app.
-When trying a similar approach with the Flash API, we get odd results.
-It would appear that when a Flash client logs in, and then another Flash client logs in, they get different results from the room.getUserList method.
-Even when the userlist is taken out of the equation, there are still 1009 and 1088 errors.
-I have been searching through the examples, the documentation, and the forums, all to no avail.
-I am desperate for assistance.

I have sought for the past 8 days to get help from your customer support. I have written post after post, explaining in as great a detail as I know how, providing code snippets, error outputs, begging and pleading for some sort of helpful response. If the culmination of all that effort on my part is for you to take umbrage and tell me to refer to your examples...I don't know what else I am supposed to do. If you don't get why that is frustrating, especially when we are a paying client of yours, then I don't know what to say.
wylkyn
Posts: 18
Joined: 26 May 2010, 16:19

Post by wylkyn »

I do want to add that it was not my intention to insult anyone. If my frustration has made my posts turn brusque and undiplomatic, or if I have given insult to anyone, I apologize. All I want is some help with my problem. I'm not really a jerk...just at my wits end, as I have said before.
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Post by Lapo »

When we ask for steps to reproduce the problem we really asks for a action by action description.
-It would appear that when a Flash client logs in, and then another Flash client logs in, they get different results from the room.getUserList method.
If this was true none of our applications would work.
Evidently something is missing in your description.
Can you please explain the steps that lead to the misbehavior?

Example:
User connects
User logs in Zone Z1
User joins Room A
User sends message to User X
User sends request to extension (explain what request does)
...
...
Another things that would helps a lot is seeing the debug transcript of the API. This is point 4 of our Issues Posting Rules:

4- Copy and paste the SmartFoxClient debug output obtained by turning on the debug flag.

Finally I have taken the time to simply take the AS3 Template application provided with every SmartFox download and apply a small modification.

The default example does the following:
1- Connect
2- Login as anonymous user in simpleChat Zone
3- Join the "autoJoin" Room of the Zone

I have added a method that dumps the contents of the userList of the joined Room. This is done when a new user joins or leaves the Room.

This way you can add/remove multiple users and see the updated content the the User List using the Room.getUserList() method that you have reported as not working.

The example works as expected. Users are all in synch and they all see the same User List.

Download sources here:
http://www.smartfoxserver.com/temp/UserListTest.zip
Lapo
--
gotoAndPlay()
...addicted to flash games
wylkyn
Posts: 18
Joined: 26 May 2010, 16:19

Post by wylkyn »

I think I have discovered the source of the problem. The main difference between your test app and our app is that we are using a custom login extension. This requires me to call smartfox.getRoomList() to update our roomlist. When I take this call out, the returned userlist matches up with the other client (yay!). The call to getRoomList is only in the joinRoom handler, not in the userEnterRoom handler - that's why they were different for the two clients: one was already in the room, and the other was coming in.

So I guess my question is, why would calling getRoomList change the returned userlist? I don't want to have to get rid of my roomlist, but I have tried all sorts of different arrangements of the code, and the only way to make it work seems to be to take the call out completely. I've tried removing the handler to see if it has to do with my own code, but even if I just make the getRoomList call without listening for the event, it still messes up the incoming userlist.

I'm not implying that there is a bug with the server code or anything - just trying to see if this gives you any idea of where the source of the problem might be. It could be my code, it could be our extension code...I'm just hoping for some indication of why this would be causing the problem.
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Post by Lapo »

The call to getRoomList is only in the joinRoom handler, not in the userEnterRoom handler - that's why they were different for the two clients: one was already in the room, and the other was coming in.
This is not the way the getRoomList is meant to work. That's why we emphasize that it's better to take a look at the examples before jumping into the coding.

If you take a closer look to any example you will see that the getRoomList call/event is handled BEFORE any room is joined and never used again in the course of the application.

The RoomList event downloads the full room list from the Server. From that moment on your client will only receive updates about new Rooms being added or removed.

Obtaining a new Room List while your app is running will erase all your local data including the user lists obtained by joining one or more Rooms.

Solution:
Simply send (from server) or request (from client) the RoomList before joining the first Room.

Additional note:
In a recent API release we have added further checks to avoid that, even if the room list is recreated at any time, the local user lists are preserved.

Here's the download:
http://forums.smartfoxserver.com/viewtopic.php?t=7543
Lapo
--
gotoAndPlay()
...addicted to flash games
Post Reply