unity client doesnt get uservar of type sfsobject
unity client doesnt get uservar of type sfsobject
hey guys
mayxbe i found annother bug, on server i create a new uservariable and put in a sfsobject
i also try to read data from the uservariable and trtace it out and it works, but in unity client this is returns the warning:
if(smartFox.MySelf.GetVariable("inv") == null){
Debug.LogWarning("uservar doesnt exist ");
}
so the client cant find the variable...
Whats the prob?
Greetz
Robert
mayxbe i found annother bug, on server i create a new uservariable and put in a sfsobject
i also try to read data from the uservariable and trtace it out and it works, but in unity client this is returns the warning:
if(smartFox.MySelf.GetVariable("inv") == null){
Debug.LogWarning("uservar doesnt exist ");
}
so the client cant find the variable...
Whats the prob?
Greetz
Robert
-
- Posts: 1297
- Joined: 14 Mar 2008, 07:52
- Location: Sweden
Yes please - paste code snippets
Full Control - maker of Unity/C# and Java SFS API and indie games
Follow on twitter: http://twitter.com/thomas_h_lund
Follow on twitter: http://twitter.com/thomas_h_lund
ok here some code, i cant post the extra methods since they are to complicated and very important for our project....:
server code:
server trace:
client code:
client trace:
that was it....
and i dont call the method on startup where maybe the var doesnt exist yet, it doesnt matter when i call it...
enough info?
hope you can help me
server code:
Code: Select all
ISFSObject inv = extension.getPlayersInv(sfsUser);
UserVariable uvar = new SFSUserVariable("inv", inv);
if(inv == null){
uvar.setNull();
extension.trace("inv == null");
}
try{
sfsUser.setVariable(uvar);
}
catch(SFSVariableException excp){
extension.trace(excp);
}
extension.trace("Reading UVAR:" + sfsUser.getVariable("inv").getSFSObjectValue().getInt("length"));
server trace:
Code: Select all
05 Jul 2011 14:25:35,446 INFO [com.smartfoxserver.v2.controllers.ExtensionController-1] Extensions - {sfsFps}: returning inv
05 Jul 2011 14:25:35,446 INFO [com.smartfoxserver.v2.controllers.ExtensionController-1] Extensions - {sfsFps}: Reading UVAR:24
client code:
Code: Select all
Debug.LogWarning("inloader");
ISFSObject inv = new SFSObject();
if(smartFox.MySelf.GetVariable("inv") == null){
Debug.LogWarning("uservar doesnt exist :( ");
}
else{
inv = smartFox.MySelf.GetVariable("inv").GetSFSObjectValue();
Debug.LogWarning("hasloaded");
int length = inv.GetInt("length");
blabla }
client trace:
Code: Select all
Debug.LogWarning("inloader");
Debug.LogWarning("uservar doesnt exist :( ");
that was it....
and i dont call the method on startup where maybe the var doesnt exist yet, it doesnt matter when i call it...
enough info?
hope you can help me
I just tested it out on RC3 and it works fine :
Server side:
User user = (User) event.getParameter(SFSEventParam.USER);
UserVariable uID = new SFSUserVariable("id", 1);
uID.setHidden(false);
List<UserVariable> vars = Arrays.asList(uID);
getApi().setUserVariables(user, vars);
client side:
Debug.Log(sfClient.MySelf.GetVariable("id"));
client debug :
[UVar: id, type: INT, value: 1]
Server side:
User user = (User) event.getParameter(SFSEventParam.USER);
UserVariable uID = new SFSUserVariable("id", 1);
uID.setHidden(false);
List<UserVariable> vars = Arrays.asList(uID);
getApi().setUserVariables(user, vars);
client side:
Debug.Log(sfClient.MySelf.GetVariable("id"));
client debug :
[UVar: id, type: INT, value: 1]
-
- Posts: 1297
- Joined: 14 Mar 2008, 07:52
- Location: Sweden
Maybe your client code is run before the var is actually sent to the client?
/Thomas
/Thomas
Full Control - maker of Unity/C# and Java SFS API and indie games
Follow on twitter: http://twitter.com/thomas_h_lund
Follow on twitter: http://twitter.com/thomas_h_lund
-
- Posts: 1297
- Joined: 14 Mar 2008, 07:52
- Location: Sweden
Will look into it!
/T
/T
Full Control - maker of Unity/C# and Java SFS API and indie games
Follow on twitter: http://twitter.com/thomas_h_lund
Follow on twitter: http://twitter.com/thomas_h_lund
Who is online
Users browsing this forum: No registered users and 33 guests