Code: Select all
public void OnExtensionResponse(object data, string type)
{
// Handle XML responses
if (type == SmartFoxClient.XTMSG_TYPE_XML)
{
SFSObject responseData = (SFSObject)data;
// TODO: check command and perform required actions
}
// Handle RAW responses
else if (type == SmartFoxClient.XTMSG_TYPE_STR)
{
string responseData = (string)data;
// TODO: check command and perform required actions
}
else if (type == SmartFoxClient.XTMSG_TYPE_JSON)
{
JsonData responseData = (JsonData)data;
SimpGridNode test = JsonMapper.ToObject<SimpGridNode>(responseData["nodes"].ToJson());
Debug.Log(test.column);
}
}
And I kept getting the following error:
Code: Select all
Error 3 The non-generic method 'LitJson.JsonMapper.ToObject(LitJson.JsonReader)' cannot be used with type arguments C:\xxx\LoginGUI.cs 219 44 Unity
although in the documentation of the litJson library (http://litjson.sourceforge.net/doc/manual.html#quickstart.mapping) it is mentioned that this should be possible.
So I downloaded the sourcecode of the LitJson and the sources of the SmartFoxClient and added the following lines to JsonMapper in SmartFoxClient:
Code: Select all
public static T ToObject<T>(JsonReader reader)
{
return (T)ReadValue(typeof(T), reader);
}
public static T ToObject<T>(TextReader reader)
{
JsonReader json_reader = new JsonReader(reader);
return (T)ReadValue(typeof(T), json_reader);
}
public static T ToObject<T>(string json)
{
JsonReader reader = new JsonReader(json);
return (T)ReadValue(typeof(T), reader);
}
After building and importing the dll into my .net application the problem was solved.
Now I wondered if this is a bug in the SmartFoxClient API or if i should use another method?
Thx in advance and sorry for my poor English.