Add RealTimeChartsWithSignalRAndAngular: migrate the SignalR + Angular real-time charts sample - #2139
Open
vladimir-pecanac-main wants to merge 1 commit into
Conversation
…-charts-signalr-angular Consolidates the three branches of CodeMazeBlog/realtime-charts-signalr-angular (master, signalR-client-specific-messages, signalR-automatic-reconnect) into one sample under aspnetcore-features, beside HowToCallSignalRAspDotNet. - Retarget the server to net10.0. - ChartHub carries every method the three articles teach. BroadcastChartData keeps its single-argument form and the client-specific overload is renamed to BroadcastChartDataToClient, because SignalR does not support hub method overloads and throws at MapHub time. - signalr.service.ts is a three-way merge of the three branches: the stored connectionId and the client-specific invoke, plus withAutomaticReconnect, logging and the reconnect handlers. - onreconnected now refreshes the stored connectionId from its own argument. A reconnect is a new connection, so the previously stored id was stale. - Add onreconnecting and onclose handlers. - TimerManager drops the unused AutoResetEvent and null-checks its fields. - Fix broadcastedData, ChartModel.data: number[] and AppComponent implements OnInit. - Add a Tests project: xunit and Moq, seven tests over the hub methods. Angular stays at 13.2; upgrading it is separate work.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Migrates the sample behind three SignalR articles out of the legacy per-article repository
CodeMazeBlog/realtime-charts-signalr-angularand into CodeMazeGuides, as one folder underaspnetcore-features, beside the existingHowToCallSignalRAspDotNet.The legacy repository served three articles from three branches:
/netcore-signalr-angular-realtime-charts(master)/how-to-send-client-specific-messages-using-signalr(signalR-client-specific-messages)/signalr-automatic-reconnect-option(signalR-automatic-reconnect)CodeMazeGuides has one
main, so the three branches collapse into one tree.What is in here
net10.0retarget of the server. Angular stays at 13.2 deliberately — CodeMazeGuides already hosts Angular front ends at 12.2, 13.1 and 14.0, and an Angular 13 to 22 upgrade is separate work with its own budget.ChartHubnow carries every method the three articles teach.BroadcastChartData(List<ChartModel>)keeps its form; the client-specific version is renamedBroadcastChartDataToClient(List<ChartModel>, string). The two cannot coexist under one name: SignalR throwsNotSupportedException: Duplicate definitions of 'BroadcastChartData'. Overloading is not supported.atMapHubtime.signalr.service.tsis a three-way hand merge — it is the one file all three branches modify.connectionId; the reconnect branch addswithAutomaticReconnect(). Neither branch has both, so neither was wrong. Together, every reconnect invalidates the stored id silently.onreconnectednow takes the id it is already handed and assigns it.onreconnectingandonclosehandlers added.TimerManagerdrops anAutoResetEventthat was constructed, passed to the timer and never read, and null-checks its two fields (twoCS8602onnet10.0).broadcastedDataspelling,ChartModel.data: number[], andAppComponent implements OnInit.Testsproject (xunit + Moq, matchingHowToCallSignalRAspDotNet), seven tests over the hub methods.dotnet buildanddotnet test: 0 warnings, 0 errors, 7/7 passing on net10.0. The merged hub maps and the host starts clean.