Skip to content

Commit

Permalink
refactor: remove onquitcallbackwrapper from interface
Browse files Browse the repository at this point in the history
  • Loading branch information
aarijimam committed Nov 20, 2024
1 parent b197726 commit 77c825f
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 13 deletions.
1 change: 0 additions & 1 deletion Assets/PlayroomKit/modules/Interfaces/IPlayerBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ public interface IPlayerBase
public T GetState<T>(string key);
public Profile GetProfile();
public Action OnQuit(Action<string> callback);
public void InvokePlayerOnQuitCallback(string id);
public void Kick(Action onKickCallBack = null);

public void WaitForState(string stateKey, Action<string> onStateSetCallback = null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,6 @@ public Action OnQuit(Action<string> callback)
return default;
}

public void InvokePlayerOnQuitCallback(string id)
{
throw new NotImplementedException();
}

public void Kick(Action onKickCallBack = null)
{
_ubb.CallJs("Kick", null, null, true, _id);
Expand Down
6 changes: 1 addition & 5 deletions Assets/PlayroomKit/modules/Player/LocalPlayerService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,7 @@ public Action OnQuit(Action<string> callback)
Debug.Log($"OnQuit is not implemented for local");
return null;
}

public void InvokePlayerOnQuitCallback(string id)
{
throw new NotImplementedException();
}


public void Kick(Action onKickCallBack = null)
{
Expand Down
13 changes: 12 additions & 1 deletion Assets/PlayroomKit/modules/Player/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,18 @@ public void WaitForState(string StateKey, Action<string> onStateSetCallback = nu

public void InvokePlayerOnQuitCallback()
{
_playerService.InvokePlayerOnQuitCallback(id);
// Attempt the cast and throw an exception if it fails
if ((_playerService is PlayerService playerService))
{
playerService.InvokePlayerOnQuitCallback(id);
}
else
{
Debug.LogWarning("InvokePlayerOnQuitCallback is only supported o build");
}

// Invoke the method on the casted object

}

//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;
}

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

0 comments on commit 77c825f

Please sign in to comment.