This article is a mirror article of machine translation, please click here to jump to the original article.

View: 57741|Reply: 3

[Source] ASP.NET Core SignalR Distributed Chat System [with source code]

[Copy link]
Posted on 2021-4-16 20:27:41 | | | |
ASP.NET Core SignalR is an open-source library that simplifies the ability to add real-time web functionality to applications. Real-time web functionality allows server-side code to instantly push content to clients.

For SignalR :

Apps that require frequent updates from the server. Examples include games, social networks, polls, auctions, maps, and GPS apps.
Dashboards and monitoring applications. Examples include company dashboards, instant sales updates, or travel alerts.
Collaborative applications. Examples of collaboration apps include whiteboard apps and team meeting software.
Apps that require notifications. Social networks, email, chat, gaming, travel alerts, and many other apps all use notifications.

review

asp.net mvc4.0 Installing SignalR (1)
http://www.itsvse.com/thread-3837-1-1.html

mvc 4.0 How to use SignalR (2)
http://www.itsvse.com/thread-3838-1-1.html

SignalR for websocket communication (3)
http://www.itsvse.com/thread-3845-1-1.html

WebSocket Signalr Communication Authentication [Source Code]
https://www.itsvse.com/thread-3464-1-1.html

documentation

The hyperlink login is visible.
The hyperlink login is visible.

About the configuration

The hyperlink login is visible.

Authorization verification

The hyperlink login is visible.

First, let's take a look at the renderings to simulate SignalR being deployed on different servers, as shown below:



Create a new project that ASP.NET Core 3.1

In Solution Explorer, right-click the project and select Add > Client Libraries.
In the Add Client Library dialog box, for Provider, select unpkg.
For Library, enter@microsoft/signalr@latest
Select Select Select Specific Files, expand the Dist/Browser folder, and select signalr.js and signalr.min.js.
Set the Target Location to wwwroot/js/signalr/ and select Install.




Create a new TestHub file in your project,Authentication is supported, the code is as follows:

To support distribution, you need to install the Microsoft.AspNetCore.SignalR.StackExchangeRedis package, using the nuget installation command as follows:

In the Startup files ConfigureServices and Configure to register the service and configuration, the code is as follows:

The main code on the frontend is as follows:

YesProactively push messages to users through the controller, the code is as follows:


Source code download:The hyperlink login is visible.




Previous:.NET/C# operations Redis unordered collections
Next:Simple use of the ORM framework SqlSugar
 Landlord| Posted on 2021-4-23 13:07:14 |
SignalR adds cross-domain support for remote access
https://www.itsvse.com/thread-9627-1-1.html
Posted on 2022-11-16 14:44:40 |
Learning in learning... Learning
Posted on 2022-11-28 21:06:41 |
Do you have a front-end instance?
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com