diff --git a/samples/SocialWeather/PersistentConnectionLifeTimeManager.cs b/samples/SocialWeather/PersistentConnectionLifeTimeManager.cs index f0af31544a..7df866b47a 100644 --- a/samples/SocialWeather/PersistentConnectionLifeTimeManager.cs +++ b/samples/SocialWeather/PersistentConnectionLifeTimeManager.cs @@ -22,7 +22,7 @@ namespace SocialWeather public void OnConnectedAsync(ConnectionContext connection) { connection.Metadata["groups"] = new HashSet(); - connection.Metadata["format"] = "json"; + connection.Metadata["format"] = connection.GetHttpContext().Request.Query["formatType"].ToString(); _connectionList.Add(connection); } diff --git a/samples/SocialWeather/Pipe/PipeWeatherStreamFormatter.cs b/samples/SocialWeather/Pipe/PipeWeatherStreamFormatter.cs index 6da67b8067..78f2210102 100644 --- a/samples/SocialWeather/Pipe/PipeWeatherStreamFormatter.cs +++ b/samples/SocialWeather/Pipe/PipeWeatherStreamFormatter.cs @@ -31,16 +31,16 @@ namespace SocialWeather.Pipe temperature = int.MinValue; } - if (tokens.Length < 2 || !long.TryParse(tokens[1], out reportTime)) - { - temperature = int.MinValue; - } - - if (tokens.Length < 3 || !Enum.TryParse(tokens[2], out weather)) + if (tokens.Length < 2 || !Enum.TryParse(tokens[1], out weather)) { weather = (Weather)(-1); } + if (tokens.Length < 3 || !long.TryParse(tokens[2], out reportTime)) + { + reportTime = int.MinValue; + } + return new WeatherReport { Temperature = temperature, diff --git a/samples/SocialWeather/SocialWeatherEndPoint.cs b/samples/SocialWeather/SocialWeatherEndPoint.cs index 17889ec1aa..9b6ee0a547 100644 --- a/samples/SocialWeather/SocialWeatherEndPoint.cs +++ b/samples/SocialWeather/SocialWeatherEndPoint.cs @@ -32,7 +32,7 @@ namespace SocialWeather public async Task ProcessRequests(ConnectionContext connection) { var formatter = _formatterResolver.GetFormatter( - (string)connection.Metadata["formatType"]); + (string)connection.Metadata["format"]); while (await connection.Transport.Reader.WaitToReadAsync()) { diff --git a/samples/SocialWeather/wwwroot/index.html b/samples/SocialWeather/wwwroot/index.html index 2e64cc60eb..e2b38c8381 100644 --- a/samples/SocialWeather/wwwroot/index.html +++ b/samples/SocialWeather/wwwroot/index.html @@ -67,7 +67,7 @@ span.style.color = color; } - let connectUrl = `ws://${document.location.host}/weather/ws?formatType=json`; + let connectUrl = `ws://${document.location.host}/weather?formatType=json`; let webSocket = new WebSocket(connectUrl); webSocket.onopen = event => { updateStatus('Connected', 'green');