From c8d7f04826e000b03d30803da038f5cc59c8f1e2 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Wed, 4 Mar 2020 21:57:42 -0500 Subject: [PATCH] signalr redis support. remove old azure signalr refs --- src/Core/GlobalSettings.cs | 2 +- src/Notifications/Notifications.csproj | 4 ++-- src/Notifications/Startup.cs | 27 ++++++++++---------------- 3 files changed, 13 insertions(+), 20 deletions(-) diff --git a/src/Core/GlobalSettings.cs b/src/Core/GlobalSettings.cs index 3c7a0d4d70..2d26949f9c 100644 --- a/src/Core/GlobalSettings.cs +++ b/src/Core/GlobalSettings.cs @@ -157,7 +157,7 @@ namespace Bit.Core public class NotificationsSettings : ConnectionStringSettings { - public string AzureSignalRConnectionString { get; set; } + public string RedisConnectionString { get; set; } } public class NotificationHubSettings diff --git a/src/Notifications/Notifications.csproj b/src/Notifications/Notifications.csproj index 812f3fa26d..decb496244 100644 --- a/src/Notifications/Notifications.csproj +++ b/src/Notifications/Notifications.csproj @@ -8,8 +8,8 @@ - - + + diff --git a/src/Notifications/Startup.cs b/src/Notifications/Startup.cs index f906578c1e..757f6189be 100644 --- a/src/Notifications/Startup.cs +++ b/src/Notifications/Startup.cs @@ -57,9 +57,13 @@ namespace Bit.Notifications MessagePack.Resolvers.ContractlessStandardResolver.Instance }; }); - if(!string.IsNullOrWhiteSpace(globalSettings.Notifications?.AzureSignalRConnectionString)) + if(!string.IsNullOrWhiteSpace(globalSettings.Notifications?.RedisConnectionString)) { - signalRServerBuilder.AddAzureSignalR(globalSettings.Notifications.AzureSignalRConnectionString); + signalRServerBuilder.AddStackExchangeRedis(globalSettings.Notifications.RedisConnectionString, + options => + { + options.Configuration.ChannelPrefix = "Notifications"; + }); } services.AddSingleton(); services.AddSingleton(); @@ -105,25 +109,14 @@ namespace Bit.Notifications app.UseAuthentication(); app.UseAuthorization(); - // Add SignlarR - var useAzureSignalR = !string.IsNullOrWhiteSpace( - globalSettings.Notifications?.AzureSignalRConnectionString); - if(useAzureSignalR) - { - app.UseAzureSignalR(routes => routes.MapHub("/hub")); - } - // Add endpoints to the request pipeline. app.UseEndpoints(endpoints => { - if(!useAzureSignalR) + endpoints.MapHub("/hub", options => { - endpoints.MapHub("/hub", options => - { - options.ApplicationMaxBufferSize = 2048; // client => server messages are not even used - options.TransportMaxBufferSize = 4096; - }); - } + options.ApplicationMaxBufferSize = 2048; // client => server messages are not even used + options.TransportMaxBufferSize = 4096; + }); endpoints.MapDefaultControllerRoute(); }); }