Example #1
0
    IEnumerator SQLGetPlayerName(string _userId, SqlGetPlayerNameCallback callback)
    {
        WWWForm form = new WWWForm();
        //URL Command
        string URL = getPlayerNameURL + "userId=" + _userId;

        UnityWebRequest download = UnityWebRequest.Post(URL, form);

        //Send Request
        download.SendWebRequest();

        //Waiting for response
        while (!download.isDone)
        {
            yield return(new WaitForSeconds(0.2f));
        }

        //Read response
        ReaderHandlerGetPlayerName(download.downloadHandler.text, _userId, callback);
    }
Example #2
0
    void ReaderHandlerGetPlayerName(string text, string _userId, SqlGetPlayerNameCallback callback)
    {
        GetPlayerNameCommandLog command = GetPlayerNameCommandLog.none;

        string[] lines = text.Split('|');

        GetPlayerNameResponse getPlayerNameResponse = new GetPlayerNameResponse();

        if (GetPlayerNameCommandLog.TryParse(lines[0].Substring(0, lines[0].IndexOf(':')), out command))
        {
            getPlayerNameResponse.command = command;
        }

        if (command == GetPlayerNameCommandLog.succes)
        {
            getPlayerNameResponse.userName = lines[1].Substring(lines[1].IndexOf(':'));
            getPlayerNameResponse.userId   = _userId;
        }

        callback(getPlayerNameResponse);
    }
Example #3
0
 public void GetPlayerName(string _userId, SqlGetPlayerNameCallback callback)
 {
     StartCoroutine(SQLGetPlayerName(_userId, callback));
 }