Skip to content

Commit

Permalink
refactor: onquit uses player service now
Browse files Browse the repository at this point in the history
  • Loading branch information
aarijimam committed Nov 25, 2024
1 parent 02d6632 commit 343f12b
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 19 deletions.
2 changes: 2 additions & 0 deletions Assets/PlayroomKit/modules/Interfaces/IPlayerBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ public interface IPlayerBase
public void WaitForState(string stateKey, Action<string> onStateSetCallback = null);

protected static Action onKickCallBack = null;

public void InvokePlayerOnQuitCallback(string id);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,14 +130,14 @@ void Unsubscribe()
return Unsubscribe;
}

public void OnQuitWrapperCallback(string id)
private void OnQuitWrapperCallback(string id)
{
if (OnQuitCallbacks != null)
foreach (var callback in OnQuitCallbacks)
callback?.Invoke(id);
}

internal void InvokePlayerOnQuitCallback(string id)
public void InvokePlayerOnQuitCallback(string id)
{
OnQuitWrapperCallback(id);
}
Expand Down
5 changes: 5 additions & 0 deletions Assets/PlayroomKit/modules/Player/LocalPlayerService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,11 @@ public void WaitForState(string stateKey, Action<string> onStateSetCallback = nu
CallbackManager.RegisterCallback(onStateSetCallback, key);
DebugLogger.Log($"Callback registered, the key is: {key}");
}

public void InvokePlayerOnQuitCallback(string id)
{
Debug.LogWarning("InvokePlayerOnQuitCallback is only supported on build");
}
}
}
}
Expand Down
17 changes: 1 addition & 16 deletions Assets/PlayroomKit/modules/Player/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,22 +139,7 @@ public void WaitForState(string StateKey, Action<string> onStateSetCallback = nu

public void InvokePlayerOnQuitCallback()
{
if (_playerService is PlayerService playerService)
{
playerService.InvokePlayerOnQuitCallback(id);
}
#if UNITY_EDITOR || DEBUG
else if (_playerService is BrowserMockPlayerService playerService2)
{
playerService2.InvokePlayerOnQuitCallback(id);
}
#endif
else
{
Debug.LogWarning("InvokePlayerOnQuitCallback is only supported on build");
}


_playerService.InvokePlayerOnQuitCallback(id);
}

//DI END
Expand Down
2 changes: 1 addition & 1 deletion Assets/PlayroomKit/modules/Player/PlayerService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ void Unsubscribe()
return Unsubscribe;
}

internal void InvokePlayerOnQuitCallback(string id)
public void InvokePlayerOnQuitCallback(string id)
{
OnQuitWrapperCallback(id);
}
Expand Down

0 comments on commit 343f12b

Please sign in to comment.