Unity3d/SmartFoxServer 解析 ISFSArray

Unity3d/SmartFoxServer Parse ISFSArray

我正在将一个数组从我的 SmartFoxServer 扩展传递到我的 Unity3d 游戏,但我很难解析。以下是我在分机中发送它的方式:

SFSObject resObj = new SFSObject();  
ISFSArray myArray= new SFSArray();

myArray.addUtfString("some String");
myArray.addUtfString("another string");
myArray.addUtfString("more string");

resObj.putSFSArray("myArray", myArray);
send("mySentData", resObj, gameExt.getGameRoom().getUserList()); 

在我的 Unity3d C# 代码中,我执行以下操作:

ISFSArray myNewArray= dataObject.GetSFSArray("myArray");

但是,我不确定如何为每个字符串解析数组。我试过这样的事情:

 for (int i = 0; i <= myNewArray.Size(); i++)
 {
   String w = cardsDealt[0];
 }

但这会报错;有关如何执行此操作的任何提示:

谢谢

不要将字符串放在 sfsArray 中,将它们放在一个 sfsObject 中:

服务器:

ISFSObject resObj = new SFSObject();
resObj.putUtfString("name1",value1);
resObj.putUtfString("name2",value2);
resObj.putUtfString("name3",value3);
send("mySentData", resObj, gameExt.getGameRoom().getUserList());

客户:

private void onExtensionResponse(BaseEvent evt)
{
    string cmd = evt.Params["cmd"].ToString();
    if(cmd == "mySentData")
    {
        ISFSObject dataObject= evt.Params["params"] as ISFSObject;

        string str1 = dataObject.GetUtfString("name1");
        string str2 = dataObject.GetUtfString("name2");
        string str3 = dataObject.GetUtfString("name3");
    }
}