@@ -87,6 +87,61 @@ static string BuildApiDescription()
8787 - Multi-language support (English, Portuguese, Spanish, French, German)
8888 - Request tracking with correlation IDs
8989 - Optimistic concurrency control for updates
90+ - Real-time notifications via SignalR
91+
92+ ## SignalR Hub
93+
94+ **WebSocket Endpoint**: `/hub/bookstore`
95+
96+ ### Events (Server → Client)
97+
98+ The server broadcasts the following events to all connected clients:
99+
100+ - **BookCreatedNotification** - Sent when a book is created
101+ ```json
102+ {
103+ "entityId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
104+ "title": "Clean Code",
105+ "eventType": "BookCreated",
106+ "timestamp": "2025-12-28T16:00:00Z"
107+ }
108+ ```
109+
110+ - **BookUpdatedNotification** - Sent when a book is updated
111+ - **BookDeletedNotification** - Sent when a book is deleted
112+
113+ ### Connection Example
114+
115+ **JavaScript/TypeScript**:
116+ ```javascript
117+ const connection = new signalR.HubConnectionBuilder()
118+ .withUrl("/hub/bookstore")
119+ .withAutomaticReconnect()
120+ .build();
121+
122+ connection.on("BookCreatedNotification", (notification) => {
123+ console.log("Book created:", notification);
124+ });
125+
126+ await connection.start();
127+ ```
128+
129+ **C# (.NET)**:
130+ ```csharp
131+ var connection = new HubConnectionBuilder()
132+ .WithUrl("https://localhost:7001/hub/bookstore")
133+ .WithAutomaticReconnect()
134+ .Build();
135+
136+ connection.On<BookNotification>("BookCreatedNotification", notification =>
137+ {
138+ Console.WriteLine($"Book created: {notification.Title}");
139+ });
140+
141+ await connection.StartAsync();
142+ ```
143+
144+ For more details, see the [SignalR Guide](https://github.com/yourusername/bookstore/blob/main/docs/signalr-guide.md).
90145 """ ;
91146 }
92147}
0 commit comments