update web requset data
This commit is contained in:
@@ -14,14 +14,31 @@ public class Authorization : MonoBehaviour
|
||||
|
||||
[SerializeField] private TMP_InputField _codeInputField;
|
||||
[SerializeField] private Button _codeAcceptButton;
|
||||
[SerializeField] private TMP_Text _errorText;
|
||||
[SerializeField] private UIInputField _inputField;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
var clientData = _clientDataService.data;
|
||||
if(clientData != null)
|
||||
if(_clientDataService.data != null)
|
||||
{
|
||||
Debug.LogWarning($"данные клианта загружены: город - {clientData.city}, найдено тэгов - {clientData.games.Count}");
|
||||
Debug.LogWarning($"данные клианта {_clientDataService.data.id} загружены: город - {(Cities)_clientDataService.data.city}, найдено тэгов - {_clientDataService.data.games.Count}");
|
||||
UniTask.Void(async ()=>
|
||||
{
|
||||
Response<int> result = new Response<int>();
|
||||
int counter = 0;
|
||||
|
||||
while(result.responseData == 0)
|
||||
{
|
||||
Debug.LogWarning($"ещё не все метки найдены ({counter})");
|
||||
result = await _networkService.GetAsync<int>("game/find", $"id={_clientDataService.data.id}", $"game={counter}");
|
||||
Debug.LogWarning(result.responseCode + "/" + result.responseData);
|
||||
counter++;
|
||||
|
||||
await UniTask.Delay(500);
|
||||
}
|
||||
|
||||
Debug.LogWarning($"поздравляем! Ваше место в общем зачете - {result.responseData}");
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -46,42 +63,37 @@ public class Authorization : MonoBehaviour
|
||||
private async UniTask SendCode(string inputFieldText)
|
||||
{
|
||||
CityUniqueCode cityUniqueCode = null;
|
||||
_networkService.OnGetResponse += CheckResponseAdmin;
|
||||
cityUniqueCode = await _networkService.GetAsync<CityUniqueCode>($"auth/admin/{inputFieldText}");
|
||||
var resultAdmin = await _networkService.GetAsync<CityUniqueCode>($"auth/admin/{inputFieldText}");
|
||||
cityUniqueCode = resultAdmin.responseData;
|
||||
|
||||
async void CheckResponseAdmin(int responseCode)
|
||||
if(resultAdmin.responseCode == 0)
|
||||
{
|
||||
_networkService.OnGetResponse -= CheckResponseAdmin;
|
||||
var message = "Нет соединения с сервером";
|
||||
Debug.LogError(message);
|
||||
_inputField.ShowErrorAsync(message).Forget();
|
||||
}
|
||||
else if (resultAdmin.responseCode == 404)
|
||||
{
|
||||
Debug.LogWarning("такого админа нет в базе. ищем город...");
|
||||
|
||||
if(responseCode == 0) Debug.LogError("Нет соединения с сервером");
|
||||
else if (responseCode == 404)
|
||||
var result = await _networkService.GetAsync<Client>($"auth/{inputFieldText}");
|
||||
Debug.Log(_clientDataService.citiesTranslation[result.responseData.city]);
|
||||
|
||||
if(result.responseCode == 404)
|
||||
{
|
||||
Client client = new Client();
|
||||
Debug.LogWarning("такого админа нет в базе. ищем город...");
|
||||
|
||||
_networkService.OnGetResponse += CheckResponse;
|
||||
client = await _networkService.GetAsync<Client>($"auth/{inputFieldText}");
|
||||
|
||||
void CheckResponse(int responseCode)
|
||||
{
|
||||
_networkService.OnGetResponse -= CheckResponse;
|
||||
|
||||
if(responseCode == 404)
|
||||
{
|
||||
Debug.LogError("такого кода нет в базе");
|
||||
}
|
||||
else if(responseCode == 0) Debug.LogError("Нет соединения с сервером");
|
||||
else if( responseCode == 200)
|
||||
{
|
||||
_clientDataService.data = client;
|
||||
Debug.Log(client.city.ToString());
|
||||
}
|
||||
}
|
||||
Debug.LogError(result.responseText);
|
||||
_inputField.ShowErrorAsync(result.responseText).Forget();
|
||||
}
|
||||
else if(responseCode == 200)
|
||||
else if(result.responseCode == 0) Debug.LogError("Нет соединения с сервером");
|
||||
else if(result.responseCode == 200)
|
||||
{
|
||||
Debug.Log(cityUniqueCode.city);
|
||||
_clientDataService.data = result.responseData;
|
||||
Debug.Log(result.responseData.city.ToString());
|
||||
}
|
||||
}
|
||||
else if(resultAdmin.responseCode == 200)
|
||||
{
|
||||
Debug.Log(cityUniqueCode.city);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user