/// <summary> /// Called when a message is received from the server, and is passed in deserialized data. /// </summary> /// <param name="message">Deserialized data</param> private async Task OnMessage(JObject message) { var response = new JObject(); if (message["msg"] != null) { response["ack"] = message["msg"].Value <int>(); } bool write = false; if (message["requests"] != null) { JArray responses = await Responder.ProcessRequests(message["requests"].Value <JArray>()); if (responses.Count > 0) { response["responses"] = responses; } write = true; } if (message["responses"] != null) { JArray requests = await Requester.ProcessResponses(message["responses"].Value <JArray>()); if (requests.Count > 0) { response["requests"] = requests; } write = true; } if (write) { await Connector.Write(response); } }