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 <mail@bergmania.dk> --------- Co-authored-by: Bjarke Berg <mail@bergmania.dk>
This commit is contained in:
@@ -7,8 +7,6 @@ using Umbraco.Cms.Core;
|
||||
using Umbraco.Cms.Core.Configuration.Models;
|
||||
using Umbraco.Cms.Core.Hosting;
|
||||
using Umbraco.Cms.Core.Services;
|
||||
using Umbraco.Cms.Core.Web.Mvc;
|
||||
using Umbraco.Cms.Web.Common.Controllers;
|
||||
using Umbraco.Cms.Web.Common.Routing;
|
||||
using Umbraco.Extensions;
|
||||
|
||||
@@ -54,8 +52,8 @@ public sealed class BackOfficeAreaRoutes : IAreaRoutes
|
||||
case RuntimeLevel.Install:
|
||||
case RuntimeLevel.Upgrade:
|
||||
case RuntimeLevel.Run:
|
||||
|
||||
MapMinimalBackOffice(endpoints);
|
||||
endpoints.MapHub<BackofficeHub>(_umbracoPathSegment + Constants.Web.BackofficeSignalRHub);
|
||||
break;
|
||||
case RuntimeLevel.BootFailed:
|
||||
case RuntimeLevel.Unknown:
|
||||
|
||||
8
src/Umbraco.Cms.Api.Management/Routing/BackofficeHub.cs
Normal file
8
src/Umbraco.Cms.Api.Management/Routing/BackofficeHub.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
|
||||
namespace Umbraco.Cms.Api.Management.Routing;
|
||||
|
||||
public class BackofficeHub : Hub
|
||||
{
|
||||
public async Task SendPayload(object payload) => await Clients.All.SendAsync("payloadReceived", payload);
|
||||
}
|
||||
@@ -56,6 +56,7 @@ public static partial class Constants
|
||||
/// The "base" path to the Management API
|
||||
/// </summary>
|
||||
public const string ManagementApiPath = "/management/api/";
|
||||
public const string BackofficeSignalRHub = "/backofficeHub";
|
||||
|
||||
public static class Routing
|
||||
{
|
||||
|
||||
@@ -45,7 +45,7 @@ public class BackOfficeAreaRoutesTests
|
||||
var endpoints = new TestRouteBuilder();
|
||||
routes.CreateRoutes(endpoints);
|
||||
|
||||
Assert.AreEqual(1, endpoints.DataSources.Count);
|
||||
Assert.AreEqual(2, endpoints.DataSources.Count);
|
||||
var route = endpoints.DataSources.First();
|
||||
Assert.AreEqual(2, route.Endpoints.Count);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user