Merge pull request #1736 from aspnet/release/2.1
Add new SignalR scenarios (#1730)
This commit is contained in:
commit
6547edb58a
|
|
@ -10,23 +10,34 @@ namespace BenchmarkServer.Hubs
|
||||||
{
|
{
|
||||||
public class EchoHub : Hub
|
public class EchoHub : Hub
|
||||||
{
|
{
|
||||||
public async Task Echo(int duration)
|
public async Task Broadcast(int duration)
|
||||||
{
|
{
|
||||||
|
var sent = 0;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var t = new CancellationTokenSource();
|
var t = new CancellationTokenSource();
|
||||||
t.CancelAfter(TimeSpan.FromSeconds(duration));
|
t.CancelAfter(TimeSpan.FromSeconds(duration));
|
||||||
while (!t.IsCancellationRequested && !Context.ConnectionAborted.IsCancellationRequested)
|
while (!t.IsCancellationRequested && !Context.ConnectionAborted.IsCancellationRequested)
|
||||||
{
|
{
|
||||||
await Clients.All.SendAsync("echo", DateTime.UtcNow);
|
await Clients.All.SendAsync("send", DateTime.UtcNow);
|
||||||
|
sent++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Console.WriteLine(e);
|
Console.WriteLine(e);
|
||||||
}
|
}
|
||||||
|
Console.WriteLine("Broadcast exited: Sent {0} messages", sent);
|
||||||
|
}
|
||||||
|
|
||||||
Console.WriteLine("Echo exited");
|
public Task Echo(DateTime time)
|
||||||
|
{
|
||||||
|
return Clients.Client(Context.ConnectionId).SendAsync("send", time);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task EchoAll(DateTime time)
|
||||||
|
{
|
||||||
|
return Clients.All.SendAsync("send", time);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,9 +8,16 @@
|
||||||
},
|
},
|
||||||
"Connections": 10,
|
"Connections": 10,
|
||||||
"Duration": 20,
|
"Duration": 20,
|
||||||
"Warmup": 2
|
"Warmup": 2,
|
||||||
|
"Path": "/echo"
|
||||||
},
|
},
|
||||||
"SignalRBroadcast": {
|
"SignalRBroadcast": {
|
||||||
"Path": "/echo"
|
"ClientProperties": { "Scenario": "broadcast" }
|
||||||
|
},
|
||||||
|
"SignalREcho": {
|
||||||
|
"ClientProperties": { "Scenario": "echo" }
|
||||||
|
},
|
||||||
|
"SignalREchoAll": {
|
||||||
|
"ClientProperties": { "Scenario": "echoAll" }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue