// Successfull room Join
public function handleJoinOk(o:Object):void
{
var roomId:int = int(o.body.@r)
var roomVarsXml:XMLList = o.body
var userListXml:XMLList = o.body.uLs.u
var playerId:int = int(o.body.pid.@id)
// Set current active room
sfs.activeRoomId = roomId
// get current Room and populates usrList
var currRoom:Room = sfs.getRoom(roomId)
// Clear the old data, we need to start from a clean list
currRoom.clearUserList() /// <---- HERE currRoom is null
// Set the player ID
// -1 = no game room
sfs.playerId = playerId
...
It seems that the room creation itself was succesful as I get the following info to the server console:
Now that I change 'isGame'-variable to false, Smartfox doesn't crash but it does not dispatch an event telling whether or not the creation
was successful. What am I missing here?
It's indispensable that you receive the current list of rooms from the server before you create new ones.
If you use a default login the getRoomList() method is called for you behind the scenes. If you use a custom login procedure simply make sure to call that method after a successful login
I also tried to make a workaround and send custom message to server extension which would create the room instead. However, even the room is successfully created by the extension, clients in the same zone get no notification about that.
Ok, the reason is that you are not yet in a room.
For security reasons you are very limited before you have at least joined one room.
You should create a container room, maybe hidden if you prefer (use a Limbo type room), where to autojoin the user and from there perform any other actions.
How about if you add a single comment to the sources related to this issue? I just lost 4 hours trying to investigate this issue. A single comment would have been a lot help!
It seems that the automated roomlistupdate is performed AFTER the event regarding to successful login has been dispatched. This is a bit irritating because now I cannot perform the autoJoin-in the login handler but I must create a timer that triggers the autoJoin sometime later? Am I correct?
How about if you add a single comment to the sources related to this issue? I just lost 4 hours trying to investigate this issue. A single comment would have been a lot help!
You mean a comment about the fact that you should be joined? It's all over the place in the docs... The first examples, the code templates, the forums.
... Because if I perform the autoJoin in the login handler, the system will crash in similar way because room list hasn't been received yet.
You can follow these steps:
1- handle the login
2- send the room list
3- perform the autojoin
I think the basic problem is that the system crashes if used incorrectly.
If you ship a product, you should never assume that users use it correctly. If customer uses your product, I think it is reasonable to assume that it does not crash but gives an error in case user did something wrong. Most of the time, like in this case it is an user error but the simplest thing you could do to help us developers would be to add those error codes, and pass them as events if required.
Current scenario:
1. make a mistake
2. crawl web, documents, forums about the issue
3. possibly post a message, wait for an answer
4. fix the problem
Better scenario:
1. make a mistake
2. get an error such as ROOM_LIST_NOT_UPDATED from the api function you used or as a separate event
3. fix the problem
In which scenario you think the developer might be most satisfied?