Skip to content

Commit 6069610

Browse files
Zeegaanbergmania
andauthored
v14: Implement backoffice signalR hub (#16723)
* Implement backoffice signalR hub * Fix test * Refactor to use object instead of string * Update src/Umbraco.Cms.Api.Management/Routing/BackofficeHub.cs Co-authored-by: Bjarke Berg <[email protected]> --------- Co-authored-by: Bjarke Berg <[email protected]>
1 parent 46acd51 commit 6069610

File tree

4 files changed

+11
-4
lines changed

4 files changed

+11
-4
lines changed

src/Umbraco.Cms.Api.Management/Routing/BackOfficeAreaRoutes.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
using Umbraco.Cms.Core.Configuration.Models;
88
using Umbraco.Cms.Core.Hosting;
99
using Umbraco.Cms.Core.Services;
10-
using Umbraco.Cms.Core.Web.Mvc;
11-
using Umbraco.Cms.Web.Common.Controllers;
1210
using Umbraco.Cms.Web.Common.Routing;
1311
using Umbraco.Extensions;
1412

@@ -54,8 +52,8 @@ public void CreateRoutes(IEndpointRouteBuilder endpoints)
5452
case RuntimeLevel.Install:
5553
case RuntimeLevel.Upgrade:
5654
case RuntimeLevel.Run:
57-
5855
MapMinimalBackOffice(endpoints);
56+
endpoints.MapHub<BackofficeHub>(_umbracoPathSegment + Constants.Web.BackofficeSignalRHub);
5957
break;
6058
case RuntimeLevel.BootFailed:
6159
case RuntimeLevel.Unknown:
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
using Microsoft.AspNetCore.SignalR;
2+
3+
namespace Umbraco.Cms.Api.Management.Routing;
4+
5+
public class BackofficeHub : Hub
6+
{
7+
public async Task SendPayload(object payload) => await Clients.All.SendAsync("payloadReceived", payload);
8+
}

src/Umbraco.Core/Constants-Web.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ public const string
5656
/// The "base" path to the Management API
5757
/// </summary>
5858
public const string ManagementApiPath = "/management/api/";
59+
public const string BackofficeSignalRHub = "/backofficeHub";
5960

6061
public static class Routing
6162
{

tests/Umbraco.Tests.UnitTests/Umbraco.Web.Common/Routing/BackOfficeAreaRoutesTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public void RuntimeState_All_Routes(RuntimeLevel level)
4545
var endpoints = new TestRouteBuilder();
4646
routes.CreateRoutes(endpoints);
4747

48-
Assert.AreEqual(1, endpoints.DataSources.Count);
48+
Assert.AreEqual(2, endpoints.DataSources.Count);
4949
var route = endpoints.DataSources.First();
5050
Assert.AreEqual(2, route.Endpoints.Count);
5151

0 commit comments

Comments
 (0)