set user variables

Post here your questions about Actionscript and Java server side extensions development.

Moderators: Lapo, Bax

shlomi
Posts: 83
Joined: 21 Feb 2010, 10:38
Location: Israel

set user variables

Postby shlomi » 04 Mar 2010, 21:27

hi,

can someone please explain me what is the difference between the both:

Code: Select all

user.properties.put("id", id);


and

Code: Select all

Map<String, UserVariable> vars = new HashMap<String, UserVariable>();
vars.put("id", new UserVariable(id, TYPE_NUMBER));


what i found is the 1st one allow me to get this variable just on the server side, and the second just in the client side. is this right?

p.s. the code is in Java.

tnx

Shlomi.
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 06 Mar 2010, 06:54

The first code stores some data in the server-side-only properties object, clients are not notified.

The second code looks like is incomplete.
Probably you were also going to call the setUserVariables(...), right?
In this case you are setting User Variables which are also synchronized with the clients. Any player/user in the same Room with User whose variables are changed will receive the updated variables.

A simple example with User Variables is the AvatarChat, which is also provided in AS3 here -> viewtopic.php?t=6669
Lapo
--
gotoAndPlay()
...addicted to flash games
shlomi
Posts: 83
Joined: 21 Feb 2010, 10:38
Location: Israel

Postby shlomi » 07 Mar 2010, 07:12

Lapo wrote:The first code stores some data in the server-side-only properties object, clients are not notified.

The second code looks like is incomplete.
Probably you were also going to call the setUserVariables(...), right?
In this case you are setting User Variables which are also synchronized with the clients. Any player/user in the same Room with User whose variables are changed will receive the updated variables.

A simple example with User Variables is the AvatarChat, which is also provided in AS3 here -> viewtopic.php?t=6669


yes you right.. i'm calling the setUserVariables() to store it.

thanks.

Shlomi.
User avatar
Carl Lydon
Posts: 298
Joined: 12 Nov 2007, 16:15
Location: NYC
Contact:

Re: set user variables

Postby Carl Lydon » 27 Sep 2014, 02:38

Lapo, in SFS2X is it possible to set a user variable locally only on the client side? I want to be joined to a room that doesn't have the userVar broadcasting flag active, set some things through an extension, and also set the variable client -side to match.

Because:

1. I want to be able to keep track of which users are in certain limbo rooms, so I want them to be able to join those rooms

2. I want to be able to change a userVar through the extension while in a limbo room, leave the room and come back, and be able to read those user vars correctly without having received a userVarUpdate (to avoid traffic)

"setVariable" seems to come up in As3 client side but I can only see examples of setting a new variable, not changing an existing one. Also, setting it doesn't seem to work.
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: set user variables

Postby Lapo » 27 Sep 2014, 10:29

Carl Lydon wrote:Lapo, in SFS2X is it possible to set a user variable locally only on the client side? I want to be joined to a room that doesn't have the userVar broadcasting flag active, set some things through an extension, and also set the variable client -side to match.

You can do that, but not with UserVariables which are meant to be updated across clients.
In SFS2X you can use local properties like this:

Code: Select all

user.properties["someProperty"] = "Hello World"



1. I want to be able to keep track of which users are in certain limbo rooms, so I want them to be able to join those rooms

I don't understand how this should work

2. I want to be able to change a userVar through the extension while in a limbo room, leave the room and come back, and be able to read those user vars correctly without having received a userVarUpdate (to avoid traffic)

I don't think I understand this one either.
1) In an SFS1.x LimboRoom you don't receive any broadcast events, so UserVariables are not supposed to be broadcast to anyone.
2) How can you change UserVariables on the server side and not send the update to the client?


"setVariable" seems to come up in As3 client side but I can only see examples of setting a new variable, not changing an existing one. Also, setting it doesn't seem to work.

setVariable does both. If the variable exists it is updated otherwise it is created.

Maybe you should explain what you trying to do in steps and adding a bit of context.
Thanks
Lapo

--

gotoAndPlay()

...addicted to flash games
User avatar
Carl Lydon
Posts: 298
Joined: 12 Nov 2007, 16:15
Location: NYC
Contact:

Re: set user variables

Postby Carl Lydon » 27 Sep 2014, 21:14

Ok, I thought I was adding a lot of context!

1. I want to be able to keep track of which users are in certain limbo rooms, so I want them to be able to join those rooms

I don't understand how this should work



When users join a room that represents what they're doing (such as visiting the map screen or closet, store etc) you can monitor that activity either through an extension function that is triggered as users enter and leave a room, or by simply looking at the room on the admin tool. I don't think that's too strange or hard to understand? I've had several projects where we kept track of user activity based on the rooms that they visited (analytics) I'm just explaining why I want the user to be joined to a room rather than joined to no room.


I don't think I understand this one either.
1) In an SFS1.x LimboRoom you don't receive any broadcast events, so UserVariables are not supposed to be broadcast to anyone.
2) How can you change UserVariables on the server side and not send the update to the client?


In my question I specified that this was SFS2X, not 1X. I'm making the equivalent of a Limbo room by not setting the broadcast flag, to avoid unnecessary bandwidth. Apparently an extension can update a variable and not broadcast it in SFS2X. Actually I asked the extension guy to turn on the flag and I'm still not getting the update.

Regardless of my purpose, my only question is:

what is the syntax to change a user variable locally only, if that is possible?

We used to have documentation that gave suggestive notes and example code for almost any function. Now we have:

public function setVariable(itemVariable:IMMOItemVariable):void
Parameters
itemVariable:IMMOItemVariable


I'm not very competent at getting the info I need from such sparse writing :-) : (A) How to actually write it (B) If it works client side. What I tried doesn't seem to be changing the variable.

If this is not actually possible, or if my question is too hard to understand, i will probably just duplicate the info in the user variable in a way that I CAN update that info manually on the client side, which I have done before, I was just hoping to make it more elegant by editing the user var directly.

My friend is telling me that it isn't possible to do, I'm just checking from the source first.
User avatar
Carl Lydon
Posts: 298
Joined: 12 Nov 2007, 16:15
Location: NYC
Contact:

Re: set user variables

Postby Carl Lydon » 27 Sep 2014, 22:38

I think it says here that what I'm trying to do is not possible. I think it SHOULD be possible and useful in certain situations but I got my answer :-)

viewtopic.php?t=8281

Return to “Server Side Extension Development”

Who is online

Users browsing this forum: No registered users and 31 guests