Clearing user variable

Post here your questions about the Unity / .Net / Mono / Windows 8 / Windows Phone 8 API for SFS2X

Moderators: Lapo, Bax

COB
Posts: 68
Joined: 28 Dec 2010, 08:54

Clearing user variable

Postby COB » 20 Jun 2011, 05:16

I'm trying to clear some user variable with such code:

Code: Select all

List<UserVariable> userVars = new List<UserVariable>();
userVars.Add( new SFSUserVariable("localRobotId",null));
smartFox.Send ( new SetUserVariablesRequest(userVars) );

However, I don't observe OnUserVarsUpdate event when I clear variable this way. Is this normal? Do I have to set variable to "" instead of null to notify other players?
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 20 Jun 2011, 08:40

The code on the sending client side doesnt do any validation or checking of any kind. It sends the array raw to the server as-is.

When getting the data from the server it checks each variable and determines of they contain NULL - if so, then the variable is deleted locally in the client. And then it calls the USER_VARIABLES_UPDATE

What the server does I do not know in details. Marco?

/Thomas
Full Control - maker of Unity/C# and Java SFS API and indie games
Follow on twitter: http://twitter.com/thomas_h_lund
COB
Posts: 68
Joined: 28 Dec 2010, 08:54

Postby COB » 20 Jun 2011, 09:45

So, I should get the notification. Maybe server deletes variable (I can see this in admin tool) and doesn't pass any information to the clients then?
User avatar
Lapo
Site Admin
Posts: 23009
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 20 Jun 2011, 13:44

Maybe, can you confirm it?
Users that will receive the notification are only those in the same room.
Also, please always specify which server version you are using?

thnx
Lapo
--
gotoAndPlay()
...addicted to flash games
COB
Posts: 68
Joined: 28 Dec 2010, 08:54

Postby COB » 20 Jun 2011, 17:34

I have Debug.Log("something") as the first line in OnUserVarsUpdate. For sure I see this log when I set "localRobotId". I see also that it appears in admin tool for the specific user. On the other hand when I set "localRobotId" to null for this player it disappears in admin tool, but I see no log generated in OnUserVarsUpdate. I'm pretty sure that there is no notification in that case and this is not good for me, because I spawn/delete automatically some prefab depending on that variable presence. In such case I can change code to set this variable to "", not to null and then I will get notifications. However, this may be also considered as a bug, so can you please check this?
I use SFS2X RC2.
COB
Posts: 68
Joined: 28 Dec 2010, 08:54

Postby COB » 19 Jul 2011, 05:25

This problem concerns also room variables. I see no event on clients when some room variables are cleared by the server. However, they disappear in room monitor in admin panel. When variables are set everything is ok and events are fired.
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 16 Aug 2011, 11:29

Found an issue when debug was set to true. Dumping the data to the log was causing a failure to safely write the NULL value to the log.

I've added a check in the next version of the API to handle this properly. At least I now get nice callbacks on the client:

Code: Select all

[SFS - INFO] Message: SetUserVariables { Message id: 12 }
{ Dump: }

   (int) u: 42
   (sfs_array) vl:
      (sfs_array)
         (utf_string) var3
         (byte) 0
         (null) NULL
      
   

User var update
Changed vars:1


Thanks for reporting
Full Control - maker of Unity/C# and Java SFS API and indie games

Follow on twitter: http://twitter.com/thomas_h_lund
COB
Posts: 68
Joined: 28 Dec 2010, 08:54

Postby COB » 18 Aug 2011, 18:39

When this fix will be implemented? I had to do add lot of not pretty code to my app and set variables to "", because of this.

By the way, I have a question. What should happen when user leaves server - will user variable change event be fired? In fact, there is a change because they are cleared, but situation is a bit different.
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 21 Aug 2011, 11:20

This should really only happen when you run debug = true. If its false it should not happen. Otherwise hit me with a PM with an email address and I'll send you a SVN build.

But there is a planned update to the API soon - days / a week'ish.

What is supposed to happen on user leaving - I actually do not know. Try to ask in the server forums is my best advise!

/T
Full Control - maker of Unity/C# and Java SFS API and indie games

Follow on twitter: http://twitter.com/thomas_h_lund

Return to “SFS2X C# API”

Who is online

Users browsing this forum: No registered users and 23 guests