i try used on server smarfox
Collection<String> name=new ArrayList<String>();
name.add("a");name.add("b");
sfsobject.putUtfStringArray("name",name)
but client unity
string[] name1 = dt.GetUtfStringArray("name");
print name i got a empty array name1 // []
sorry my english not good pls help me ! tkanks you
how i can send String array to client unity
-
- Posts: 21
- Joined: 15 May 2018, 08:34
Re: how i can send String array to client unity
We tested this and everything works as expected.
Server Extension:
Unity client, in the Extension Response listener:
(tested in the Editor for both standalone platform and webgl platform)
Output:
Please make sure you are using the latest version of the C# API (currently v1.7.6).
Server Extension:
Code: Select all
ISFSObject dataObj = new SFSObject();
Collection<String> name = new ArrayList<String>();
name.add("a");
name.add("b");
dataObj.putUtfStringArray("name", name);
send("test", dataObj, sender);
Unity client, in the Extension Response listener:
(tested in the Editor for both standalone platform and webgl platform)
Code: Select all
ISFSObject para = (ISFSObject) evt.Params["params"];
Debug.Log(para.GetUtfStringArray("name")[0]);
Debug.Log(para.GetUtfStringArray("name")[1]);
Output:
Code: Select all
a
UnityEngine.Debug:Log(Object)
MainController:OnExtensionResponse(BaseEvent) (at Assets/Scripts/MainController.cs:298)
Sfs2X.Core.EventDispatcher:DispatchEvent(BaseEvent)
Sfs2X.SmartFox:ProcessEvents()
MainController:Update() (at Assets/Scripts/MainController.cs:41)
b
UnityEngine.Debug:Log(Object)
MainController:OnExtensionResponse(BaseEvent) (at Assets/Scripts/MainController.cs:299)
Sfs2X.Core.EventDispatcher:DispatchEvent(BaseEvent)
Sfs2X.SmartFox:ProcessEvents()
MainController:Update() (at Assets/Scripts/MainController.cs:41)
Please make sure you are using the latest version of the C# API (currently v1.7.6).
Paolo Bax
The SmartFoxServer Team
The SmartFoxServer Team
Who is online
Users browsing this forum: No registered users and 27 guests