HandleRoomList() Clearing All Rooms

Post here all your questions related with SmartFoxServer .Net/Unity3D API

Moderators: Lapo, Bax

Posts: 26
Joined: 05 May 2009, 02:46
Location: Los Angeles, CA

HandleRoomList() Clearing All Rooms

Postby dlong » 14 Oct 2009, 19:49

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...

Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 14 Oct 2009, 19:52

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.


Return to “.Net / Unity3D API”

Who is online

Users browsing this forum: No registered users and 3 guests