I have some problem with room variable.
I want set a room variable true when the room, created by some user is full.
I want that this value will be fire to all user insiede room and inside the lobby, so the button of the game is destroy if the game is started and if some user exit from the room i don't want show the button again.
When some user want create a game this is the code (client side)that i use to create room:
Code: Select all
RoomSettings settings = new RoomSettings(inputNomePartita.text.Replace(" ", "").Trim());
settings.GroupId = "games";
settings.IsGame = true;
settings.MaxUsers = numeroMaxDecisoDaOwner;
settings.MaxSpectators = 0;
SFSRoomVariable roomVariableStart = new SFSRoomVariable("gameStarted", false);
roomVariableStart.IsPersistent = true;
settings.Variables.Add(roomVariableStart);
settings.Extension = new RoomExtension(EXTENSION_ID, EXTENSION_CLASS);
sfs.Send(new CreateRoomRequest(settings, true, sfs.LastJoinedRoom));
On my extension(server side) if user enter on this room i use this code(USER_JOIN_ROOM event)):
Code: Select all
Room room=(Room) event.getParameter(SFSEventParam.ROOM);
if(room.isGame()){
SFSRoomVariable startGame=new SFSRoomVariable("gameStarted", true);
startGame.setGlobal(true);
startGame.setPersistent(true);
if(room.getMaxUsers()==room.getUserList().size()) {
room.setVariable(startGame);
}
In client side i show all button of the games, but if rooms[i].GetVariable("gameStarted").GetBoolValue()) --->If game is started, i dont want istanciate the button.
I see that only one user see the value gameStarted true(only the last user that enter inside the room), the other instead see the value false.
Inside the zone monitor i see the room variable gameStarted true, persistent and global and with true value when the room is full, but in client side only one see the value true.
Can you help me?