public void CancelHosting()
    {
        if (hosting)
        {
            MatchmakingRequest matchmakingRequest = new MatchmakingRequest();
            matchmakingRequest.SetMatchShortCode("HostedMatch");

            GameSparks.Core.GSRequestData participantData = new GameSparks.Core.GSRequestData();
            participantData.AddString("displayName", gameSparksUserID.myDisplayName);
            participantData.AddBoolean("hosting", true);
            matchmakingRequest.SetParticipantData(participantData);
            matchmakingRequest.SetMatchData(participantData);
            matchmakingRequest.SetSkill(0);
            // Cancel host
            hosting = false;
            matchmakingRequest.SetAction("cancel");
            matchmakingRequest.Send(OnMatchmakingSuccess, OnMatchmakingError);
            // Change button text to represent hosting a game
            var buttonText = hostGameButton.GetComponentsInChildren <TMPro.TextMeshProUGUI>();
            buttonText[0].text          = "Host Game";
            joinGameButton.interactable = true;
            onRefreshGamesButtonClick();
            UnblockMatchmakingButton();
        }
    }
    private void onRefreshGamesButtonClick()
    {
        BlockRefreshInput();
        // Make sure the user isn't currently hosting that way the refresh doesn't remove their hosted lobby/game
        if (!hosting)
        {
            GameSparksUserID gameSparksUserIDScript = GameObject.Find("GameSparksUserID").GetComponent <GameSparksUserID>();
            // Do a matchmaking request
            MatchmakingRequest matchmakingRequest = new MatchmakingRequest();
            matchmakingRequest.SetMatchShortCode("HostedMatch");

            GameSparks.Core.GSRequestData participantData = new GameSparks.Core.GSRequestData();
            participantData.AddString("displayName", gameSparksUserIDScript.myDisplayName);
            participantData.AddBoolean("hosting", false);
            matchmakingRequest.SetParticipantData(participantData);
            matchmakingRequest.SetMatchData(participantData);
            matchmakingRequest.SetSkill(0);
            // Store this request incase we get a throttled message
            lastMatchmakingRequest = matchmakingRequest;

            matchmakingRequest.Send(OnMatchmakingSuccess, OnMatchmakingError);
            FindGameLobbies();
        }
        else
        {
            FindGameLobbies();
        }
    }
    public void OnHostGameButtonClick()
    {
        BlockMatchmakingButton();
        joinGameButton.interactable = false;
        EventSystem.current.SetSelectedGameObject(null);

        gameSparksUserID = GameObject.Find("GameSparksUserID").GetComponent <GameSparksUserID>();

        MatchmakingRequest matchmakingRequest = new MatchmakingRequest();

        matchmakingRequest.SetMatchShortCode("HostedMatch");

        GameSparks.Core.GSRequestData participantData = new GameSparks.Core.GSRequestData();
        participantData.AddString("displayName", gameSparksUserID.myDisplayName);
        participantData.AddBoolean("hosting", true);
        matchmakingRequest.SetParticipantData(participantData);
        matchmakingRequest.SetMatchData(participantData);
        matchmakingRequest.SetSkill(0);


        if (!hosting)
        {
            hosting = true;
            // Change button text to represent canceling host
            var buttonText = hostGameButton.GetComponentsInChildren <TMPro.TextMeshProUGUI>();
            buttonText[0].text = "Cancel Host";
        }
        else
        {
            // Cancel host
            hosting = false;
            matchmakingRequest.SetAction("cancel");
            matchmakingRequest.Send(OnMatchmakingSuccess, OnMatchmakingError);
            // Change button text to represent hosting a game
            var buttonText = hostGameButton.GetComponentsInChildren <TMPro.TextMeshProUGUI>();
            buttonText[0].text          = "Host Game";
            joinGameButton.interactable = true;
            onRefreshGamesButtonClick();
            UnblockMatchmakingButton();
        }

        matchmakingRequest.Send(OnMatchmakingSuccess, OnMatchmakingError);
    }
    public void CheckHosting()
    {
        if (hosting)
        {
            MatchmakingRequest matchmakingRequest = new MatchmakingRequest();
            matchmakingRequest.SetMatchShortCode("HostedMatch");

            GameSparks.Core.GSRequestData participantData = new GameSparks.Core.GSRequestData();
            participantData.AddString("displayName", gameSparksUserID.myDisplayName);
            participantData.AddBoolean("hosting", true);
            matchmakingRequest.SetParticipantData(participantData);
            matchmakingRequest.SetMatchData(participantData);
            matchmakingRequest.SetSkill(0);
            // Store this request incase we get a throttled message
            lastMatchmakingRequest = matchmakingRequest;

            matchmakingRequest.Send(OnMatchmakingSuccess, OnMatchmakingError);
            FindGameLobbies();
        }
        hostingCheckTimer.ResetTimer();
        hostingCheckTimer.StartCountdown();
    }