Page 1 of 1

HandleRoomList() Clearing All Rooms

Posted: 14 Oct 2009, 19:49
by dlong
Hi, I'm trying to figure out the desired behavior with regards to rooms, room lists, creating rooms, etc.

In the api code, the method HandleRoomList() is clearing out all the rooms and then "rebuilding" the list based on the data being sent back from the server. The problem becomes that if you're in a room and receive a room list update you lose all other user information (such as who else is in the room). Is this expected behavior or am I possibly doing something incorrectly?

Here's the method code:

Code: Select all

      public void HandleRoomList(XmlNode xml) {

         Hashtable roomList = sfs.GetAllRooms();

         foreach ( XmlNode roomXml in XmlUtil.GetNodeList(xml, "body/rmList/rm") ) {
            int roomId = XmlUtil.GetInt(roomXml, "./@id");
            Room room = new Room(roomId,
                              XmlUtil.GetString(roomXml, "./n/node()"),
                              XmlUtil.GetInt(roomXml, "./@maxu"),
                              XmlUtil.GetInt(roomXml, "./@maxs"),
                              XmlUtil.GetBool(roomXml, "./@temp"),
                              XmlUtil.GetBool(roomXml, "./@game"),
                              XmlUtil.GetBool(roomXml, "./@priv"),
                              XmlUtil.GetBool(roomXml, "./@lmb"),
                              XmlUtil.GetInt(roomXml, "./@ucnt"),
                              XmlUtil.GetInt(roomXml, "./@scnt")

            // Handle Room Variables
            if ( XmlUtil.GetSingleNode(roomXml, "./vars") != null ) {
               PopulateVariables(room.GetVariables(), roomXml);

            // Add room
            roomList[roomId] = room;

         Hashtable parameters = Hashtable.Synchronized(new Hashtable());
         parameters.Add("roomList", roomList);

         SFSEvent evt = new SFSEvent(SFSEvent.onRoomListUpdateEvent, parameters);

The first line is the culprit here... it clears the room list hashtable out. Shouldn't we be adding/removing rooms selectively based on the data coming back from the server rather than dumping all the existing data?

Please let me know what you think...


Posted: 14 Oct 2009, 19:52
by ThomasLund
Yes - and thats actually something the SFS guys recently discovered and are fixing/fixed in the AS3 API right now.

That will be part of the next release also for the Unity API.