Skip to main content

PlayPad communication

PlayPadCommunicator

PlayPadCommunicator is an easy to use singleton being an all-in-one solution aggregating all the necessary interface implementations for external communication. This works a little differently in the final PlayPad environment and in the Editor. In the Editor you do not access majority of our services but use default, mock implementations instead. For example you cannot play in the tournament here and get your score to its leaderboard. Displayed data are some default values meant only for basic testing. For more elaborate implementations, you can provide your own.

An instance of this class is included in the JsReceiver prefab which should be included in the lobby scene.

Its public APIs:

  • PlayPadCommunicator? Instance
  • IExternalAuthenticator? ExternalAuthenticator
  • IExternalGameStatusCommunicator? GameStatusCommunicator
  • IExternalUiCommunicator? ExternalUiCommunicator
  • IExternalERC20SmartContractOperations? TokenCommunicator
  • IExternalTournamentCommunicator? TournamentCommunicator
  • IExternalLeaderboardCommunicator? LeaderboardCommunicator

IExternalAuthenticator

  • event Action<AuthData>? AuthenticationUpdated
  • UniTask<AuthData> Authenticate(CancellationToken ct = default)
  • UniTask<HandshakeInfo> InitializationMessage(...) - should be called only once per runtime
tip

SessionManager handles the whole process of authentication and connection setup. It is then recommended to use it instead of implementing whole process manually.

IExternalGameStatusCommunicator

  • void HideSplashScreen()
  • PlayStatusInfo CurrentPlayStatus { get; }
  • event Action<PlayStatusInfo>? PlayStatusUpdated
  • UniTask<PlayStatusInfo> CanPlayGame(bool autoResolve, CancellationToken ct = default) - no need for manual usage
  • UniTask<IRoom> PlayGame(PlayGameConfig config, CancellationToken ct = default)
  • `void RttUpdated(TimeSpan rtt) - used by the RttMonitor

IExternalUiCommunicator

  • UniTask Display(string name, CancellationToken ct = default) - used by methods below
  • UniTask DisplayTournamentRewards()
  • UniTask DisplayTournamentsListing()

IExternalERC20SmartContractOperations

Only important one is the method below, as it lets the developer to fetch NFTs of the player:

  • UniTask<string> GetBalance(SmartContract tokenContract, string owner, CancellationToken ct = default)

IExternalTournamentCommunicator

  • TournamentInfo? CurrentTournament
  • event Action<TournamentInfo>? TournamentUpdated
  • UniTask<TournamentInfo?> GetTournament(CancellationToken ct = default) - no need for manual usage

IExternalLeaderboardCommunicator

  • UserHighScoreInfo? UserHighScore
  • LeaderboardStatusInfo? Leaderboard
  • event Action<LeaderboardStatusInfo>? LeaderboardUpdated
  • event Action<UserHighScoreInfo>? UserHighScoreUpdated
  • UniTask<LeaderboardStatusInfo> FetchLeaderboard(CancellationToken ct = default) - no need for manual usage
  • UniTask<UserHighScoreInfo?> FetchUserHighScore(CancellationToken ct = default) - no need for manual usage