Page 1 of 1

How to remove the room variable?

Posted: 08 Feb 2012, 04:59
by wildcatz
Hi all!

I want to ask exactly how to remove the roomvariables?

When new player joining the room, the server create roomvariable named "player1", "player2", etc.

[code]
List<RoomVariable> roomVars = new ArrayList<RoomVariable>();

if (room.getVariable("player1") == null) {
roomVars.add(new SFSRoomVariable("player1", sender.getName(), false, false, true));
}
[/code]

When one of the player exiting the room, I remove the roomvariable with this code:

[code]
Room room = (Room) event.getParameter(SFSEventParam.ROOM);

if (room.getVariable("player1") != null && room.getVariable("player1").getStringValue().equals(sender.getName())) {
room.removeVariable("player1");
}
[/code]

When I check the localhost sfsadmin, it is true that the variable is removed, but when I test the flash movie, the roomvariable is still there!

Any thoughts? Thanks.

Posted: 08 Feb 2012, 21:25
by rjgtav
Hi.

The removeVariable() method of a room is for internal use, i mean, to be used only by the server. That's why it isn't documented. In order to remove the variable, you have to set that variable to null, using the sfsApi.setRoomVariables() method.