elgE
Normal11mo ago
6 replies
elg

Realtime Model Persistence

Hello, I have a question regarding Realtime Model persistence. I want the model of a particular user to persist in the room whenever they leave and the room is still in session (other users in the room remain). Upon returning, I want the model to be reapplied to the Realtime Component. From reading documentation I think RealtimeModel.destroyWhenOwnerLeaves = false should make this possible. I'm setting this flag when the model is first initialized:

protected override async void OnRealtimeModelReplaced(NetworkModel previousModel, NetworkModel currentModel)
{
  if (currentModel != null)
  {
    if (currentModel.isFreshModel)
    {
      currentModel.destroyWhenOwnerLeaves = false;
      currentModel.destroyWhenLastClientLeaves = true;
    }
  }
}

However, every time the owner of the model returns it always goes through the "fresh model" path so I think that means the model is created again instead of reapplying the persisted model. Am I understanding the persistence flags incorrectly or is there some built-in way to achieve what I'm trying to do?
Was this page helpful?