How to remove the room variable?

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

Moderators: Lapo, Bax

Post Reply
wildcatz
Posts: 13
Joined: 08 Dec 2011, 05:01

How to remove the room variable?

Post 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.
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Post 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.
Skills: SFS Pro, SFS2X, AS2.0/AS3.0, Java, HTML5/CSS3/JS, C#
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
Post Reply