Add new SignalR scenarios (#1730)

This commit is contained in:
BrennanConroy 2018-03-27 10:14:08 -07:00 committed by GitHub
parent 7a9160f3e0
commit b7e2678592
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 5 deletions

View File

@ -10,23 +10,34 @@ namespace BenchmarkServer.Hubs
{
public class EchoHub : Hub
{
public async Task Echo(int duration)
public async Task Broadcast(int duration)
{
var sent = 0;
try
{
var t = new CancellationTokenSource();
t.CancelAfter(TimeSpan.FromSeconds(duration));
while (!t.IsCancellationRequested && !Context.ConnectionAborted.IsCancellationRequested)
{
await Clients.All.SendAsync("echo", DateTime.UtcNow);
await Clients.All.SendAsync("send", DateTime.UtcNow);
sent++;
}
}
catch (Exception 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);
}
}
}

View File

@ -8,9 +8,16 @@
},
"Connections": 10,
"Duration": 20,
"Warmup": 2
"Warmup": 2,
"Path": "/echo"
},
"SignalRBroadcast": {
"Path": "/echo"
"ClientProperties": { "Scenario": "broadcast" }
},
"SignalREcho": {
"ClientProperties": { "Scenario": "echo" }
},
"SignalREchoAll": {
"ClientProperties": { "Scenario": "echoAll" }
}
}