public async Task <JsonResult> Communicate(string clientId, string channels = null, string indexes = null, string sendChannel = null, string sendData = null) { if (sendChannel != null && sendData != null) { _ = ChannelHub.SendMessageAsync(clientId, sendChannel, sendData); } if (channels == null) { return(new JsonResult(new List <object>())); } if (indexes == null) { indexes = "0"; } var channelData = await ChannelHub.GetMessagesSinceEpochAsync(clientId, channels.Split('|'), indexes.Split('|').Select(a => long.Parse(indexes)).ToArray()); return(new JsonResult(channelData)); }
public async Task <JsonResult> Communicate([FromBody] CommunicateData data) { if (data == null) { return(new JsonResult("Error")); } // Receive all messages since epoch, and optionally send data if (data.SendChannel != null && data.SendData != null) { _ = ChannelHub.SendMessageAsync(data.ClientId, data.SendChannel, data.SendData); } if (data.Channels == null) { return(new JsonResult(new List <object>())); } var channelData = await ChannelHub.GetMessagesSinceEpochAsync(data.ClientId, data.Channels, data.Indexes); return(new JsonResult(channelData)); }