IEnumerator SQSMessageDeleteAsync(string receiptHandle, string payloadString, OnMessageReceived mesgRecvCallback) { Log(string.Format("Deleting SQS message")); string requestURL = string.Format("{0}message?receiptHandle={1}", simpleQueingServiceURL, UnityWebRequest.EscapeURL(receiptHandle)); var request = new UnityWebRequest(requestURL, "DELETE"); request.SetRequestHeader("X-Api-Key", apiKey); request.downloadHandler = (DownloadHandler) new DownloadHandlerBuffer(); yield return(request.SendWebRequest()); MessageResultType messageResultType = MessageResultType.MessageReceived; string message = ""; if (request.isNetworkError) { Log("SQS DELETE Net Error: " + request.error); messageResultType = MessageResultType.NetworkError; message = request.error; } else if (request.isHttpError) { Log("SQS DELETE Http Error: " + request.error); messageResultType = MessageResultType.FailedToClaimMessage; } else { if (enableLogging) { string bodyJsonString = System.Text.Encoding.UTF8.GetString(request.downloadHandler.data); Log(bodyJsonString); } messageResultType = MessageResultType.MessageReceived; if (payloadString != null) { GamePayload gamePayload = JsonUtility.FromJson <GamePayload>(payloadString); if (gamePayload != null) { message = gamePayload.message; } else { message = payloadString; } } } if (mesgRecvCallback != null) { mesgRecvCallback(messageResultType, message); } }
/// <summary> /// Used to convert a message result type json string to IResultMonad. /// </summary> /// <param name="resultType">The result type.</param> /// <param name="body">The body of the message.</param> /// <typeparam name="T">The type of the message.</typeparam> /// <returns>The result monad.</returns> public static IResultMonad <T> ToResultMonad <T>(this MessageResultType resultType, string body) { switch (resultType) { case MessageResultType.Success: var message = JsonHelper.Decode <MessageResultSuccess <T> >(body); return(new ResultSuccess <T>(message.Result)); case MessageResultType.AccessDenied: return(new ResultAccessDenied <T>(new List <string> { "Access denied" })); default: var messageE = JsonHelper.Decode <MessageResultError <T> >(body); return(new ResultError <T>(messageE.Errors)); } }
public MessageResult(MessageResultType type, string title, string message) { Type = type; Title = title; Message = message; }
protected static ActionResult Message(MessageResultType type, string title, string message) { return(new MessageResult(type, title, message)); }