forked from aspnet/Benchmarks
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add SignalR Client and scenario (aspnet#398)
- Loading branch information
1 parent
9456d87
commit 584b3c2
Showing
16 changed files
with
716 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ namespace Benchmarks.ClientJob | |
{ | ||
public enum Worker | ||
{ | ||
Wrk | ||
Wrk, | ||
SignalR, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using System; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Benchmarks.Configuration; | ||
using Microsoft.AspNetCore.Builder; | ||
using Microsoft.AspNetCore.SignalR; | ||
|
||
namespace Benchmarks.Middleware | ||
{ | ||
public static class SignalRMiddlewareExtensions | ||
{ | ||
public static IApplicationBuilder UseSignalRMiddleware(this IApplicationBuilder builder) | ||
{ | ||
return builder.UseSignalR(route => | ||
{ | ||
route.MapHub<EchoHub>(Scenarios.GetPath(s => s.SignalRBroadcast) + "/default"); | ||
}); | ||
} | ||
} | ||
|
||
public class EchoHub : Hub | ||
{ | ||
public async Task Echo(int duration) | ||
{ | ||
try | ||
{ | ||
var t = new CancellationTokenSource(); | ||
t.CancelAfter(TimeSpan.FromSeconds(duration)); | ||
while (!t.IsCancellationRequested && !Context.Connection.ConnectionAbortedToken.IsCancellationRequested) | ||
{ | ||
await Clients.All.SendAsync("echo", DateTime.UtcNow); | ||
} | ||
} | ||
catch (Exception e) | ||
{ | ||
Console.WriteLine(e); | ||
} | ||
|
||
Console.WriteLine("Echo exited"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"Default": { | ||
"ClientName": "signalr", | ||
"Source": { | ||
"Repository": "https://github.com/aspnet/benchmarks.git", | ||
"BranchOrCommit": "brecon/signalrClientNew", | ||
"Project": "src/Benchmarks/Benchmarks.csproj" | ||
} | ||
}, | ||
"SignalRBroadcast": { | ||
"Path": "/signalr/broadcast" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.