Error in GetRoomList example?

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

Moderators: Lapo, Bax

jeff_o
Posts: 13
Joined: 03 Oct 2008, 20:59

Error in GetRoomList example?

Postby jeff_o » 05 Jan 2009, 17:48

In the example usage for GetRoomList:

SFSEvent.onRoomListUpdate += OnRoomListUpdate;

smartFox.GetRoomList()

public void OnRoomListUpdate(Hashtable roomList)
{
// Dump the names of the available rooms in the current zone
foreach (Room room in roomList)
Trace.WriteLine(room.GetName())
}

I get an error on the foreach line:

Unable to cast object of type 'System.Collections.DictionaryEntry' to type 'SmartFoxClientAPI.Data.Room'.

I am using version 1.0 final, any help with this would be much appreciated!
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 05 Jan 2009, 18:52

Ahh yes - good one

Try roomList.Values in the foreach instead of just roomList

Will fix that in the next update. If you find any other examples with bad code then poke me here - most of them are not tested but written directly as comments.
jeff_o
Posts: 13
Joined: 03 Oct 2008, 20:59

Postby jeff_o » 06 Jan 2009, 00:11

Works, thanks =] I will let you know of any other errors I come across!

Return to “.Net / Unity3D API”

Who is online

Users browsing this forum: No registered users and 18 guests