Can't get created room vars

Post here your questions about the Flash / Flex / Air API for SFS2X

Moderators: Lapo, Bax

loki
Posts: 66
Joined: 04 Apr 2010, 11:16
Location: Latvia
Contact:

Can't get created room vars

Postby loki » 16 Jan 2011, 09:08

I'm tring to create room variable when user join Lobby. But in Flash client, I can't see this variable. If I close Flash client, and then run it again, flash see room variable. And also if put subscribeRoomGroup string after code, before joinRoom, client also can see variable, but other vars that will be created after user join Lobby, are hidden from client, again need to restart client ))) Whats wrong with this room variables?

Code: Select all

smartfox.subscribeRoomGroup(user, "play_cash");
      
       SFSObject vr = SFSObject.newInstance();
      vr.putDouble("m", 120);
      vr.putUtfString("name", user.getName());
      RoomVariable var = new SFSRoomVariable("2", vr);
      var.setGlobal(true);
      var.setPrivate(true);
      Room rmg = main.zone.getRoomByName("Constancia");
      try {
         rmg.setVariable(var);
      } catch (SFSVariableException e) {
         e.printStackTrace();
      }
      
      smartfox.joinRoom(user, room);


Code: Select all

var room:Room = smartFox.roomManager.getRoomById( Number(num) );
trace("room" + room.name);
var varsArr:Array = room.getVariables();
trace("vars "+varsArr.length);


I use last version of SFS2X
User avatar
Lapo
Site Admin
Posts: 23027
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 17 Jan 2011, 16:51

Please read here:
viewtopic.php?t=9806
Lapo
--
gotoAndPlay()
...addicted to flash games
User avatar
copet80
Posts: 42
Joined: 27 Apr 2010, 22:23
Location: Australia
Contact:

Postby copet80 » 14 Feb 2011, 03:55

Hi guys, on a related topic, I'm trying to set a room variable from the client-side, is there a way to set room variable so that it's persisted as long as the server hasn't been restarted regardless if the user left the room or disconnected?

Or would I have to rely on the server-side API for this?
User avatar
Lapo
Site Admin
Posts: 23027
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 14 Feb 2011, 08:58

From server side yes, by setting the Server as the owner of the variable.
From client, no.
Lapo

--

gotoAndPlay()

...addicted to flash games
User avatar
copet80
Posts: 42
Joined: 27 Apr 2010, 22:23
Location: Australia
Contact:

Postby copet80 » 14 Feb 2011, 19:36

Thanks Lapo.

Return to “SFS2X ActionScript 3 API”

Who is online

Users browsing this forum: No registered users and 25 guests