| | | 1 | | using Elsa.Workflows.Api.RealTime.Contracts; |
| | | 2 | | using Elsa.Workflows.Runtime; |
| | | 3 | | using JetBrains.Annotations; |
| | | 4 | | using Microsoft.AspNetCore.Authorization; |
| | | 5 | | using Microsoft.AspNetCore.SignalR; |
| | | 6 | | |
| | | 7 | | namespace Elsa.Workflows.Api.RealTime.Hubs; |
| | | 8 | | |
| | | 9 | | /// <summary> |
| | | 10 | | /// Represents a SignalR hub for receiving workflow events on the client. |
| | | 11 | | /// </summary> |
| | | 12 | | [PublicAPI] |
| | | 13 | | [Authorize] |
| | | 14 | | public class WorkflowInstanceHub : Hub<IWorkflowInstanceClient> |
| | | 15 | | { |
| | | 16 | | private readonly IWorkflowRuntime _workflowRuntime; |
| | | 17 | | |
| | | 18 | | /// <inheritdoc /> |
| | 0 | 19 | | public WorkflowInstanceHub(IWorkflowRuntime workflowRuntime) |
| | | 20 | | { |
| | 0 | 21 | | _workflowRuntime = workflowRuntime; |
| | 0 | 22 | | } |
| | | 23 | | |
| | | 24 | | /// <summary> |
| | | 25 | | /// Observes a workflow instance. |
| | | 26 | | /// </summary> |
| | | 27 | | /// <param name="instanceId">The ID of the workflow instance to observe.</param> |
| | | 28 | | public async Task ObserveInstanceAsync(string instanceId) |
| | | 29 | | { |
| | | 30 | | // Join the user to the workflow instance group. |
| | 0 | 31 | | await Groups.AddToGroupAsync(Context.ConnectionId, instanceId); |
| | 0 | 32 | | } |
| | | 33 | | } |