Skip to content
This repository was archived by the owner on Dec 18, 2018. It is now read-only.

Commit 4203540

Browse files
Fix SocialWeather sample (#1313)
1 parent 1cc4098 commit 4203540

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

samples/SocialWeather/PersistentConnectionLifeTimeManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public PersistentConnectionLifeTimeManager(FormatterResolver formatterResolver)
2222
public void OnConnectedAsync(ConnectionContext connection)
2323
{
2424
connection.Metadata["groups"] = new HashSet<string>();
25-
connection.Metadata["format"] = "json";
25+
connection.Metadata["format"] = connection.GetHttpContext().Request.Query["formatType"].ToString();
2626
_connectionList.Add(connection);
2727
}
2828

samples/SocialWeather/Pipe/PipeWeatherStreamFormatter.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@ public async Task<WeatherReport> ReadAsync(Stream stream)
3131
temperature = int.MinValue;
3232
}
3333

34-
if (tokens.Length < 2 || !long.TryParse(tokens[1], out reportTime))
34+
if (tokens.Length < 2 || !Enum.TryParse<Weather>(tokens[1], out weather))
3535
{
36-
temperature = int.MinValue;
36+
weather = (Weather)(-1);
3737
}
3838

39-
if (tokens.Length < 3 || !Enum.TryParse<Weather>(tokens[2], out weather))
39+
if (tokens.Length < 3 || !long.TryParse(tokens[2], out reportTime))
4040
{
41-
weather = (Weather)(-1);
41+
reportTime = int.MinValue;
4242
}
4343

4444
return new WeatherReport

samples/SocialWeather/SocialWeatherEndPoint.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public async override Task OnConnectedAsync(ConnectionContext connection)
3232
public async Task ProcessRequests(ConnectionContext connection)
3333
{
3434
var formatter = _formatterResolver.GetFormatter<WeatherReport>(
35-
(string)connection.Metadata["formatType"]);
35+
(string)connection.Metadata["format"]);
3636

3737
while (await connection.Transport.Reader.WaitToReadAsync())
3838
{

samples/SocialWeather/wwwroot/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ <h3>Weather reports</h3>
6767
span.style.color = color;
6868
}
6969

70-
let connectUrl = `ws://${document.location.host}/weather/ws?formatType=json`;
70+
let connectUrl = `ws://${document.location.host}/weather?formatType=json`;
7171
let webSocket = new WebSocket(connectUrl);
7272
webSocket.onopen = event => {
7373
updateStatus('Connected', 'green');

0 commit comments

Comments
 (0)