public async Task ServeClient() { var ReadBuffer = new Byte[MaxBuffer]; while (IsRunning) { await Connection.GetStream().ReadAsync(ReadBuffer, 0, MaxBuffer); var commandJson = Encoding.UTF8.GetString(ReadBuffer); NetCommand<HostCommandType> command; try { command = NetCommand<HostCommandType>.Unserialize(commandJson); } catch (ArgumentException) { _ = CommandClient(new NetCommand<ClientCommandType>(ClientCommandType.InvalidCommand)); continue; } _ = InvokeCommand(command); } }