Page 1 of 1

Changing room variables server side.

Posted: 17 Nov 2010, 22:01
by mr_malee
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.

Posted: 18 Nov 2010, 16:09
by Lapo
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.