private static string ReadInfo(Communication communication) { byte[] dataLength = communication.Read(ProtocolConstants.FixedDataSize); int dataSize = BitConverter.ToInt32(dataLength, 0); byte[] data = communication.Read(dataSize); var msg = Encoding.UTF8.GetString(data); return(msg); }
private async static Task ReadAsync(Communication communication) { while (true) { try { byte[] dataLength = communication.Read(ProtocolConstants.FixedDataSize); int dataSize = BitConverter.ToInt32(dataLength, 0); byte[] data = communication.Read(dataSize); var msg = Encoding.UTF8.GetString(data); var result = await ExecuteUserRequestAsync(msg); Write(communication, result); } catch (System.IO.IOException) { return; } } }