Room.GetVariable is randomly null
Posted: 31 Jan 2019, 14:08
Hi,
i am using extension to access room variables
I collect data from room in case of SFSEvent.ROOM_VARIABLES_UPDATE.
Sometimes, the room.GetVariable("gameData"); returns null. I have not found any reason why. I tried to check it using breakpoint inside null check and i have found out, that when i call room.GetVariable("gameData") again, it has the data.
I would expect, that all the data are updated prior SFSEvent.ROOM_VARIABLES_UPDATE event, but it looks otherwise. Do you have any idea how to solve my issue?
i am using extension to access room variables
Code: Select all
public static ISFSObject GetGameData(this Room room)
{
Debug.Assert(MainThreadDispatcher.Instance.IsMainThread);
var gameDataVar = room.GetVariable("gameData");
if (gameDataVar == null)
{
Debug.LogError("Room " + room.Id + " has no gameData");
}
else
{
return gameDataVar.GetSFSObjectValue();
}
return null;
}
I collect data from room in case of SFSEvent.ROOM_VARIABLES_UPDATE.
Sometimes, the room.GetVariable("gameData"); returns null. I have not found any reason why. I tried to check it using breakpoint inside null check and i have found out, that when i call room.GetVariable("gameData") again, it has the data.
I would expect, that all the data are updated prior SFSEvent.ROOM_VARIABLES_UPDATE event, but it looks otherwise. Do you have any idea how to solve my issue?