diff --git a/samples/SocialWeather/SocialWeatherEndPoint.cs b/samples/SocialWeather/SocialWeatherEndPoint.cs index c37cfd7a29..858091705a 100644 --- a/samples/SocialWeather/SocialWeatherEndPoint.cs +++ b/samples/SocialWeather/SocialWeatherEndPoint.cs @@ -34,9 +34,9 @@ namespace SocialWeather var formatter = _formatterResolver.GetFormatter( connection.Metadata.Get("formatType")); - while (true) + WeatherReport weatherReport; + while ((weatherReport = await formatter.ReadAsync(stream)) != null) { - var weatherReport = await formatter.ReadAsync(stream); lock(_lockObj) { _lastWeatherReport = weatherReport; diff --git a/samples/SocialWeather/WeatherReport.cs b/samples/SocialWeather/WeatherReport.cs index 366630698f..0963465183 100644 --- a/samples/SocialWeather/WeatherReport.cs +++ b/samples/SocialWeather/WeatherReport.cs @@ -1,7 +1,5 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; namespace SocialWeather { @@ -13,6 +11,7 @@ namespace SocialWeather public long ReportTime { get; set; } + [JsonConverter(typeof(StringEnumConverter))] public Weather Weather { get; set; } public string ZipCode { get; set; } diff --git a/samples/SocialWeather/wwwroot/weather.html b/samples/SocialWeather/wwwroot/weather.html index 22a8f953c8..5ba5ef7710 100644 --- a/samples/SocialWeather/wwwroot/weather.html +++ b/samples/SocialWeather/wwwroot/weather.html @@ -5,9 +5,6 @@ Social weather -
-

Weather:

-
@@ -19,18 +16,43 @@ - +
+
+

Weather reports

+
+

Status: