Changing room variables server side.

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

mr_malee
Posts: 29
Joined: 08 Jun 2007, 03:21

Changing room variables server side.

Postby mr_malee » 17 Nov 2010, 22:01

not a bug, but a question. Whats the simplest way to change a room variable server side and send it back to clients?

currently the only way I see is to always create new variables, as the methods to set values are protected in the SFSRoomVariable class.

If I have one variable I want to change and send here's what I'm doing:

Code: Select all

RoomVariable someVar = new SFSRoomVariable("someVar", 10, false, true, false);

List<RoomVariable> roomVariables = new ArrayList<RoomVariable>();
roomVariables.add(someVar);

getApi().setRoomVariables(null, getParentRoom(), roomVariables);
;

now, what happens when my room variables have things changed like ownership, isGlobal... I would have to re-create those flags whenever this variable changes right?

What I would like to do is this:

Code: Select all

Room room = getParentRoom();

RoomVariable someVar = room.setRoomVariable("someVar", 10);

//here I could change some permissons
//someVar.setOwner...

getApi().setRoomVariables(null, room, room.getRoomVariables());


Is that possible to do? It doesn't seem like it.
User avatar
Lapo
Site Admin
Posts: 23026
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 18 Nov 2010, 16:09

currently the only way I see is to always create new variables, as the methods to set values are protected in the SFSRoomVariable class.

This is correct and in general it's the proper way to do it.

The attributes such as global, private etc... are very unlikely to change dynamically:
Global is typically static.
A Private variable is also very unlikely to change at runtime. And the same goes for the Persisten flag.
Lapo
--
gotoAndPlay()
...addicted to flash games

Return to “SFS2X Questions”

Who is online

Users browsing this forum: Baidu [Spider] and 74 guests