private void ProcessResults(WaitableTask actionResult, TaskResult <string> serverResult, EncounterMetadata metadata) { if (serverResult.IsError()) { actionResult.SetError(serverResult.Exception); return; } Debug.Log("Returned text from PHP: \n" + serverResult.Value); if (string.IsNullOrWhiteSpace(serverResult.Value)) { actionResult.SetError(new Exception("No text returned from the server.")); } else if (!int.TryParse(serverResult.Value, out int recordNumber)) { actionResult.SetError(new Exception(serverResult.Value)); } else if (recordNumber != metadata.RecordNumber) { actionResult.SetError(new Exception("Did not get the correct metadata from the server.")); } else { actionResult.SetCompleted(); } }
protected virtual void ProcessResults(WaitableTask result, TaskResult <string> serverOutput) { if (serverOutput == null || serverOutput.IsError()) { result.SetError(serverOutput.Exception); return; } var output = serverOutput.Value.Trim(); if (output.StartsWith("1")) { result.SetCompleted(); return; } string errorStart = "-1|"; if (output.StartsWith(errorStart, StringComparison.InvariantCultureIgnoreCase)) { var encounterLock = parser.Deserialize(output.Substring(errorStart.Length)); result.SetError(new EncounterAlreadyLockedException(encounterLock)); return; } result.SetError(new Exception("Could not unlock the encounter.")); }
protected void ProcessResults(WaitableTask task, WaitableTask serverTask, WaitableTask localTask) { if (task.IsCompleted() || !serverTask.IsCompleted() || !localTask.IsCompleted()) { return; } task.SetCompleted(); }
private void CopyValue(TaskResult source, WaitableTask destination) { if (source.IsError()) { destination.SetError(source.Exception); } else { destination.SetCompleted(); } }
protected virtual void ProcessResults(WaitableTask actionResult, TaskResult <string> serverResult, EncounterMetadata metadata) { if (serverResult.IsError()) { actionResult.SetError(serverResult.Exception); return; } Debug.Log("Returned text from PHP: \n" + serverResult.Value); if (string.IsNullOrWhiteSpace(serverResult.Value)) { actionResult.SetError(new Exception("No text returned from the server.")); return; } var splitStr = serverResult.Value.Split('|'); if (int.TryParse(splitStr[0], out var recordNumber)) { metadata.RecordNumber = recordNumber; } actionResult.SetCompleted(); }