void Awake() { GameSparks.Api.Messages.MatchNotFoundMessage.Listener = (message) => { Debug.Log("No Match Found"); }; GameSparks.Api.Messages.MatchFoundMessage.Listener += OnMatchFound; GameSparks.Core.GS.GameSparksAvailable += (isAvailable) => { if (isAvailable && GameSparksManager.PeerId() == -1) { if (useDeviceAuth) { GameSparksManager.Instance().DeviceAuthentication(OnAuthentication); } else { GameSparksManager.Instance().AuthenticateUser(userName, password, OnRegistration, OnAuthentication); } } }; }
private void OnMatchFound(GameSparks.Api.Messages.MatchFoundMessage _message) { searchingPanel.SetActive(false); foundPanel.SetActive(true); Debug.Log("Match Found!..."); StringBuilder sBuilder = new StringBuilder(); sBuilder.AppendLine("Match Found..."); sBuilder.AppendLine("Host URL:" + _message.Host); sBuilder.AppendLine("Port:" + _message.Port); sBuilder.AppendLine("Access Token:" + _message.AccessToken); sBuilder.AppendLine("MatchId:" + _message.MatchId); sBuilder.AppendLine("Opponents:" + _message.Participants.Count()); sBuilder.AppendLine("_________________"); sBuilder.AppendLine(); // we'll leave a space between the player-list and the match data foreach (GameSparks.Api.Messages.MatchFoundMessage._Participant player in _message.Participants) { sBuilder.AppendLine("Player:" + player.PeerId + " User Name:" + player.DisplayName); // add the player number and the display name to the list } matchDetails.text = sBuilder.ToString(); // set the string to be the player-list field GameSparksManager.Instance().StartNewRTSession(new RTSessionInfo(_message)); }
void UpdateUserStatus() { userStatus.text = (GameSparks.Core.GS.Available ? "Connected" : "Disconnected") + ((GameSparks.Core.GS.Authenticated && GameSparksManager.Instance().user != null) ? " | Logged in as " + GameSparksManager.Instance().user.displayName : " | Not authenticated"); }
public static void SendPacket(NetworkObject networkObject, RTData data, GameSparksRT.DeliveryIntent intent) { data.SetString((int)DataIndex.NetworkId, networkObject.networkId); GameSparksManager.Instance().SendRTData(OpCodes.NetworkObject, intent, data); }
private void OnAuthentication(AuthenticationResponse _resp) { GameSparksManager.Instance().FindPlayers(matchShortCode); }
private void OnRegistration(RegistrationResponse _resp) { GameSparksManager.Instance().FindPlayers(matchShortCode); }
void OnReadyButton() { GameSparksManager.Instance().SetPlayerReady(true); readyButton.interactable = false; }
void UpdateUserStatus() { userStatus.text = (GameSparks.Core.GS.Available ? "Connected" : "Disconnected") + " | Logged in as " + GameSparksManager.Instance().user.displayName; }