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) {
sfs.ClearRoomList();
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);
sfs.DispatchEvent(evt);
}
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...
DL