Fix SocialWeather sample (#1313)
This commit is contained in:
parent
1cc4098d3a
commit
4203540cb0
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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())
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
|
|
|
|||
Loading…
Reference in New Issue