setUserVariable doesn't update client

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

Moderators: Lapo, Bax

Luc
Posts: 18
Joined: 17 Jun 2007, 21:05

setUserVariable doesn't update client

Postby Luc » 20 Sep 2007, 12:25

In my Java server extension I have:

Code: Select all

public void handleRequest(String cmd, ActionscriptObject ao, User u, int fromRoom)
{
  if (cmd.equals("try"))
  {
    boolean aOK = u.setVariable("TEST", "3", UserVariable.TYPE_NUMBER);
  }
}


When I send the Xt message to the server, setVariable returns OK, but the client never receives an onUserVariablesUpdate message with the new value. Is this the expected behaviour?

Thanks very much.

Luc
User avatar
Lapo
Site Admin
Posts: 23027
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 20 Sep 2007, 13:27

This not the right way to do it.
You have to call the ExtensionHelper.setUserVariables() method.

If you check our java examples you'll notice that the main access to the server side framework is from the ExtensionHelper object.

More details in the javadoc -> http://www.smartfoxserver.com/docs/docP ... index.html

HTH
Lapo
--
gotoAndPlay()
...addicted to flash games
Luc
Posts: 18
Joined: 17 Jun 2007, 21:05

Postby Luc » 20 Sep 2007, 13:38

Thank you for the reply, that clears things up. I do wonder what the user.setVariable method can be used for then... It has no comments in the javadoc, so I figured wrongly this was the Java way of doing things.
User avatar
Lapo
Site Admin
Posts: 23027
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 20 Sep 2007, 13:47

It's used internally to set user variables but it is not responsible for updating the clients and all the rest.

We left a number of undocumented public methods in the docs as they could be useful in particularly advanced tasks. These methods can be used rarely and I agree that they might confuse ideas at times.
We'll add better notes and comments in the next release to avoid ambiguities.

Thanks
Lapo

--

gotoAndPlay()

...addicted to flash games
jalava
Posts: 40
Joined: 03 Sep 2007, 12:23

Postby jalava » 05 Oct 2007, 11:13

Btw, is user variables only sent after logged in user has joined some room?

I noticed that calling

ExtensionHelper.instance().setUserVariables(sfsUser, variables, true);

doesn't send onUserVariablesUpdate if done right after login.
User avatar
Lapo
Site Admin
Posts: 23027
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 05 Oct 2007, 15:50

No, of course.
Variables update is sent to all the members in the same room... but if you haven't joined any it won't work.

The steps are:

1. connect
2. log in a Zone
3. join 1 (or more) room(s)
4 ... interact with the server and other users
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “Server Side Extension Development”

Who is online

Users browsing this forum: No registered users and 55 guests