SmartFoxServer Basic user leaveRoom error

时间:2015-06-15 15:01:01

标签: actionscript-3 smartfoxserver smartfox

User 1 is opening the application from Flash and user 2 from browser

  • User 1 creates room A
  • User 2 joins room A
  • User 2 exits room A

... and I get this error:

[ RECEIVED ]: <msg t='sys'><body action='uCount' r='2' u='1'></body></msg>, (len: 60) [ RECEIVED ]: <msg t='sys'><body action='userGone' r='89'><user id='91' />, (len: 73) TypeError: Error #1009: Cannot access a property or method of a null object reference. at it.gotoandplay.smartfoxserver.handlers::SysHandler/handleUserLeaveRoom()[/Users/Lapo/Documents/Flex Builder 2/SmartFoxClient_AS3/src/it/gotoandplay/smartfoxserver/handlers/SysHandler.as:353] at Function/http://adobe.com/AS3/2006/builtin::apply() at it.gotoandplay.smartfoxserver.handlers::SysHandler/handleMessage()[/Users/Lapo/Documents/Flex Builder 2/SmartFoxClient_AS3/src/it/gotoandplay/smartfoxserver/handlers/SysHandler.as:84] at it.gotoandplay.smartfoxserver::SmartFoxClient/xmlReceived()[/Users/Lapo/Documents/Flex Builder 2/SmartFoxClient_AS3/src/it/gotoandplay/smartfoxserver/SmartFoxClient.as:327] at it.gotoandplay.smartfoxserver::SmartFoxClient/handleMessage()[/Users/Lapo/Documents/Flex Builder 2/SmartFoxClient_AS3/src/it/gotoandplay/smartfoxserver/SmartFoxClient.as:1418] at it.gotoandplay.smartfoxserver::SmartFoxClient/handleSocketData()[/Users/Lapo/Documents/Flex Builder 2/SmartFoxClient_AS3/src/it/gotoandplay/smartfoxserver/SmartFoxClient.as:1401]

  • If user 2 creates room A
  • User 1 joins room A
  • User 2 exits room A

... there is no error when user 2 exits room.

So, I have a button that connects user to server, when user is connected and joined the "lobby" room he can join and create rooms, when 2 players joined, game begins.

I am using SFS Basic with AS3, I don't call getRoomList() anywhere and I need to mention that I have another application similar to this that is working without error (same api, same server, similar function flow).

Tried different solutions, but no help...

I don't understand why I get this error on this application and the other one works fine and why do I get this error only when I create the room and I expect to get an error when any user creates room, not only when user 1 creates the room.

Any help or suggestions are greatly appreciated, I'm struggling with this problems for days...

Update: If I create a 3 players room (game room) and the game is not started and I connect 2 players and then they disconnect everything is fine, but if the game starts and then they disconnect I get this error.

1 个答案:

答案 0 :(得分:1)

我发现了这个问题,我希望通过这个答案能节省一些时间:

问题在于这一行:

sfs.getActiveRoom().getUserList().sort(randomize)[0].getName();

我使用此代码生成随机用户是第一个玩,但实际上我似乎正在更改用户列表数组(通过排序)(sfs.getActiveRoom()。getUserList())和何时用户离开了房间。繁荣!错误!空对象!

所以,我改变了这个:

   var userList:Array = new Array();
   userList = userList.concat(sfs.getActiveRoom().getUserList());
   var randomUser = userList.sort(randomize)[0].getName();