|
8 | 8 |
|
9 | 9 | namespace SignalR.OpenApi.Sample.Hubs; |
10 | 10 |
|
11 | | -/// <summary> |
12 | | -/// A sample chat hub demonstrating SignalR.OpenApi features. |
13 | | -/// </summary> |
| 11 | +/// <inheritdoc cref="IChatHub"/> |
14 | 12 | [Tags("Chat")] |
15 | | -public class ChatHub : Hub<IChatClient> |
| 13 | +public class ChatHub : Hub<IChatClient>, IChatHub |
16 | 14 | { |
17 | | - /// <summary> |
18 | | - /// Sends a message to all connected clients using separate parameters. |
19 | | - /// </summary> |
20 | | - /// <remarks> |
21 | | - /// This demonstrates hub methods with primitive parameters. |
22 | | - /// FluentValidation does not apply to primitive parameters — use a request object instead. |
23 | | - /// </remarks> |
24 | | - /// <param name="user">The name of the sending user.</param> |
25 | | - /// <param name="message">The message to send.</param> |
26 | | - /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns> |
| 15 | + /// <inheritdoc /> |
27 | 16 | [SignalROpenApiRequestExamples(typeof(SendMessageExamplesProvider))] |
28 | | - public async Task SendMessage(string user, string message) |
| 17 | + public async Task SendMessageAsync(string user, string message) |
29 | 18 | { |
30 | 19 | await this.Clients.All.ReceiveMessage(user, message); |
31 | 20 | } |
32 | 21 |
|
33 | | - /// <summary> |
34 | | - /// Sends a direct message using a request object with FluentValidation. |
35 | | - /// </summary> |
36 | | - /// <remarks> |
37 | | - /// This demonstrates hub methods with a single object parameter (flattened schema). |
38 | | - /// FluentValidation rules from <see cref="SendMessageRequestValidator"/> are applied to the OpenAPI schema. |
39 | | - /// </remarks> |
40 | | - /// <param name="request">The message request containing user and message.</param> |
41 | | - /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns> |
| 22 | + /// <inheritdoc /> |
42 | 23 | [SignalROpenApiRequestExamples(typeof(SendMessageExamplesProvider))] |
43 | | - public async Task SendDirectMessage(SendMessageRequest request) |
| 24 | + public async Task SendDirectMessageAsync(SendMessageRequest request) |
44 | 25 | { |
45 | 26 | await this.Clients.All.ReceiveMessage(request.User, request.Message); |
46 | 27 | } |
47 | 28 |
|
48 | | - /// <summary> |
49 | | - /// Replies to an existing message. |
50 | | - /// </summary> |
51 | | - /// <remarks> |
52 | | - /// This demonstrates hub methods with two object parameters (wrapped schema). |
53 | | - /// Each parameter appears as a named property in the request body. |
54 | | - /// </remarks> |
55 | | - /// <param name="originalMessage">The original message being replied to.</param> |
56 | | - /// <param name="reply">The reply message.</param> |
57 | | - /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns> |
| 29 | + /// <inheritdoc /> |
58 | 30 | [SignalROpenApiRequestExamples(typeof(ReplyToMessageExamplesProvider))] |
59 | | - public async Task ReplyToMessage(ChatMessage originalMessage, ChatMessage reply) |
| 31 | + public async Task ReplyToMessageAsync(ChatMessage originalMessage, ChatMessage reply) |
60 | 32 | { |
61 | 33 | await this.Clients.All.ReceiveMessage(reply.User, $"Re: {originalMessage.Message} — {reply.Message}"); |
62 | 34 | } |
63 | 35 |
|
64 | | - /// <summary> |
65 | | - /// Sends a message to a specific group. |
66 | | - /// </summary> |
67 | | - /// <param name="group">The target group name.</param> |
68 | | - /// <param name="user">The name of the sending user.</param> |
69 | | - /// <param name="message">The message to send.</param> |
70 | | - /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns> |
71 | | - public async Task SendToGroup(string group, string user, string message) |
| 36 | + /// <inheritdoc /> |
| 37 | + public async Task SendToGroupAsync(string group, string user, string message) |
72 | 38 | { |
73 | 39 | await this.Clients.Group(group).ReceiveMessage(user, message); |
74 | 40 | } |
75 | 41 |
|
76 | | - /// <summary> |
77 | | - /// Sends a notification to a user. The notification type is polymorphic — |
78 | | - /// use the "type" discriminator to select between "text" and "alert". |
79 | | - /// </summary> |
80 | | - /// <param name="notification">The notification to send (text or alert).</param> |
81 | | - /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns> |
| 42 | + /// <inheritdoc /> |
82 | 43 | [SignalROpenApiRequestExamples(typeof(NotificationExamplesProvider))] |
83 | | - public async Task SendNotification(Notification notification) |
| 44 | + public async Task SendNotificationAsync(Notification notification) |
84 | 45 | { |
85 | 46 | await this.Clients.All.ReceiveMessage(notification.Recipient, $"Notification: {notification.GetType().Name}"); |
86 | 47 | } |
87 | 48 |
|
88 | | - /// <summary> |
89 | | - /// Streams a countdown of numbers. |
90 | | - /// </summary> |
91 | | - /// <param name="from">The starting number.</param> |
92 | | - /// <param name="cancellationToken">Cancellation token.</param> |
93 | | - /// <returns>A stream of countdown numbers.</returns> |
94 | | - /// <example>10.</example> |
| 49 | + /// <inheritdoc /> |
95 | 50 | public async IAsyncEnumerable<int> Countdown( |
96 | 51 | int from, |
97 | 52 | [EnumeratorCancellation] CancellationToken cancellationToken) |
|
0 commit comments