Fix SocialWeather sample (#1313)

This commit is contained in:
BrennanConroy 2018-01-25 21:15:38 -08:00 committed by GitHub
parent 1cc4098d3a
commit 4203540cb0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 9 deletions

View File

@ -22,7 +22,7 @@ namespace SocialWeather
public void OnConnectedAsync(ConnectionContext connection)
{
connection.Metadata["groups"] = new HashSet<string>();
connection.Metadata["format"] = "json";
connection.Metadata["format"] = connection.GetHttpContext().Request.Query["formatType"].ToString();
_connectionList.Add(connection);
}

View File

@ -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<Weather>(tokens[2], out weather))
if (tokens.Length < 2 || !Enum.TryParse<Weather>(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,

View File

@ -32,7 +32,7 @@ namespace SocialWeather
public async Task ProcessRequests(ConnectionContext connection)
{
var formatter = _formatterResolver.GetFormatter<WeatherReport>(
(string)connection.Metadata["formatType"]);
(string)connection.Metadata["format"]);
while (await connection.Transport.Reader.WaitToReadAsync())
{

View File

@ -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');