/* * private void CreateQueueListener() * { * // SqsClient.CreateQueueAsync(QueueName, (result) => * // { * // if (result.Exception == null) * // { * // Debug.Log(@"Queue Created"); * // queueUrl = result.Response.QueueUrl; * // } * // else * // { * // Debug.LogException(result.Exception); * // } * // }); * } * * private void DeleteQueueListener() * { * // if (!string.IsNullOrEmpty(queueUrl)) * // { * // SqsClient.DeleteQueueAsync(queueUrl, (result) => * // { * // if (result.Exception == null) * // { * // Debug.Log(@"Queue Deleted"); * // } * // else * // { * // Debug.LogException(result.Exception); * // } * // }); * // } * // else * // { * // Debug.Log(@"Queue Url is empty, make sure that the queue is created first"); * // } * } * * private void SendMessageListener() * { * * if (!string.IsNullOrEmpty(queueUrl)) * { * var message = Message.text; * if (string.IsNullOrEmpty(message)) * { * Debug.Log("No Message to send"); * return; * } * * SqsClient.SendMessageAsync(queueUrl, message, (result) => * { * if (result.Exception == null) * { * Debug.Log("Message Sent"); * } * else * { * Debug.LogException(result.Exception); * } * }); * } * else * { * Debug.Log(@"Queue Url is empty, make sure that the queue is created first"); * } * } */ IEnumerator RepeatRetrieveMessage(float waitTime) { bool checkSQS = true; while (checkSQS) { yield return(new WaitForSeconds(waitTime)); if (!string.IsNullOrEmpty(queueUrl)) { SqsClient.ReceiveMessageAsync(queueUrl, (result) => { if (result.Exception == null) { //Read the message var messages = result.Response.Messages; messages.ForEach(m => { //Debug.Log(@"Message Id = " + m.MessageId); Debug.Log(@"Mesage = " + m.Body); //Process the message //[do your thing here] //var color = colorDictionay.Where(c => c.Key == m.Body).FirstOrDefault().Value; if (m.Body == "white") { for (int i = 0; i < env_light.Length; i++) { env_light[i].color = Color.white; } } if (m.Body == "red") { for (int i = 0; i < env_light.Length; i++) { env_light[i].color = Color.red; } } else if (m.Body == "blue") { for (int i = 0; i < env_light.Length; i++) { env_light[i].color = Color.blue; } } else if (m.Body == "green") { for (int i = 0; i < env_light.Length; i++) { env_light[i].color = Color.green; } } if (m.Body == "off") { for (int i = 0; i < env_light.Length; i++) { env_light[i].enabled = false; } } else if (m.Body == "on") { for (int i = 0; i < env_light.Length; i++) { env_light[i].enabled = true; } } if (m.Body == "delete") { StartCoroutine(placeObject.ClearRoom()); } if (m.Body == "undo") { StartCoroutine(placeObject.UndoPlacement()); } //Delete the message var delRequest = new Amazon.SQS.Model.DeleteMessageRequest { QueueUrl = queueUrl, ReceiptHandle = m.ReceiptHandle }; SqsClient.DeleteMessageAsync(delRequest, (delResult) => { if (delResult.Exception == null) { } else { } }); }); } else { Debug.LogException(result.Exception); } }); } else { Debug.Log(@"Queue Url is empty, make sure that the queue is created first"); } //Debug.Log ("."); } }