User coming null in onUserVariablesUpdate event

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

Moderators: Lapo, Bax

Post Reply
Rohit Sharma
Posts: 31
Joined: 05 Nov 2008, 05:27
Location: Delhi,India
Contact:

User coming null in onUserVariablesUpdate event

Post by Rohit Sharma »

Hi,
We are facing a random problem where the user object is coming null while we are capturing the onUserVariablesUpdate event.

i) The version used is 1.6.6.

ii) The error comes at random times but the occurence is always when I come out of a game room to the lobby which is a non-game room.

iii) The code flow is :-
a) On clicking exit game, sfs.getRoomList() is called.
b) When the room list arrives, joinRoom("lobby") is called.

iv) While checking the debug output what I found that :-
a) I receive the room list correctly.
b) A uVarsUpdate message is received for the game room just after the joinRoom(lobby) message is sent.
c) The error occurs after the uVarsUpdate message is received. I tried tracing the user but the user is coming null.
d) onJoinroom message comes after the error. That means the user is still in the game room when the uVarsUpdate message came. And hence it should be captured correctly.

v) I tried going through the SmartFoxClient and SysHandler code but could not get much insight. Please provide some pointers to crack the problem.

Thanks,
Rohit Sharma,
Lead Developer and Co-Founder,
Mactabilis Arts.
www.mactabilisarts.com
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Post by Lapo »

I would recommend updating to the latest 1.6.7
It is very likely that the problem is related with calling the getRoomList() multiple times. We have addressed this particular issue in the latest API psupplied with the SmartFoxServer 1.6.7

You can download the patch from here:
http://forums.smartfoxserver.com/viewtopic.php?t=6006
Lapo
--
gotoAndPlay()
...addicted to flash games
Rohit Sharma
Posts: 31
Joined: 05 Nov 2008, 05:27
Location: Delhi,India
Contact:

Post by Rohit Sharma »

Hi Lapo,

The problem still persists despite switching to SFS version 1.6.7.
I guess the problem is due to the following reason :-

i) At every onroomlistupdate we first clear the earlier room list.
ii) Then the roomlist array is populated with data for each room.
iii) Now if a user variable update comes after I have called getRoomList(), the call to room.getUser() will result in null since my room variable now refers to a different memory location which does not have any user information.
Therefore I am getting this error.

Correct me if I am wrong.

Thanks,
Rohit
Rohit Sharma,
Lead Developer and Co-Founder,
Mactabilis Arts.
www.mactabilisarts.com
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Post by Lapo »

i) At every onroomlistupdate we first clear the earlier room list.
Can you please better explain this?
Why do you clear the earlier room list? And how?
Lapo
--
gotoAndPlay()
...addicted to flash games
Rohit Sharma
Posts: 31
Joined: 05 Nov 2008, 05:27
Location: Delhi,India
Contact:

Post by Rohit Sharma »

Hi Lapo,

I put it the wrong way. Sorry for that. I was infact talking about the SFS code in SysHandler.as that is written to handle the onRoomListUpdate. Inside the code the first thing that is done is clearRoomList().
I hope that makes it clear.

Thanks,
Rohit Sharma,
Lead Developer and Co-Founder,
Mactabilis Arts.
www.mactabilisarts.com
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Post by Lapo »

Hi,
thanks for the clarification.
It looks like there is an API mismatch.

Please download the latest API from here
Then point your classpath to the new API and recompile your application.
Make sure that the getVersion() method returns 1.6.1

This should solve the issue.
Let us know.
Lapo
--
gotoAndPlay()
...addicted to flash games
Rohit Sharma
Posts: 31
Joined: 05 Nov 2008, 05:27
Location: Delhi,India
Contact:

Post by Rohit Sharma »

Hi Lapo,

Thanks for the clarification.
The link that you mentioned above for SFS patch 1.6.7 contains the older client side API's which gives SFS version 1.5.9 and not the one which you
provided in your last reply. Probably, that was the reason the problem did
not resolve.
I have integrated the new API's and have not received any error till now but the error comes at random, so cannot be 100 % sure.
But after going through the API's it seems, this will solve the problems related to user coming null when onUserLeaveRoom or onUserVariablesUpdate comes after getRoomList() is called.
I will monitor the swf and see if the problem persists.

Thanks,
Rohit
Rohit Sharma,
Lead Developer and Co-Founder,
Mactabilis Arts.
www.mactabilisarts.com
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Post by Lapo »

Thank you, keep us posted.
Lapo
--
gotoAndPlay()
...addicted to flash games
Post Reply