|
|
Posted on 1/17/2017 2:04:03 PM
|
|
|
|

SignalR is an integrated client-server library that allows browser-based clients and ASP.NET-based server components to conduct two-way multi-step conversations. In other words, the conversation allows for a single stateless request/response data exchange without restrictions; It will continue until it is explicitly closed. The conversation takes place over a permanent connection, allowing the client to send multiple messages to the server and allow the server to reply accordingly, and notably, also allow the server to send asynchronous messages to the client. It is similar to AJax and is based on existing technology. itself is a complex. In general, SignalR uses long polling of Javascrip{filtering}t to achieve client-side communication. After the advent of WebSockets, SignalR also supported WebSockets communication. Of course, SignalR also uses server-side task parallel processing technology to improve server scalability. It targets the entire .NET Framework platform, it is not limited to hosting applications, and it is also a cross-platform open source project, supporting Mono 2.10+, which makes it an alternative implementation option for Web APIs, but it is much better than ASP.NET MVC's Web API in terms of server-side online processing, and more importantly, it can be used on Web Forms. Above is the demo tutorial:
The server we use for websocket is signalr, and then we use owin and host it on the console!!!!
The full name of OWIN is Open Web Interface for .NET.
If we parse only from the name, we can get this information: OWIN is an open web interface for the .NET platform.
So who is the interface between the web interface? It is the interface between the web application and the web server, and OWIN is the interface between the .NET web application and the web server.
Why do you need such an interface? Because. NET web application runs on a web server, and the .NET web application needs to receive the user's request through the web server and send the response content to the user through the web server. Without such an interface, the .NET web application would depend on the specific web server it was running, for example ASP.NET the application would depend on IIS. With this interface, ASP.NET application only needs to rely on this abstract interface and does not care about the web server it is running.
Therefore, the role of OWIN is to decouple by introducing a set of abstract interfaces. NET web application and web server, once again demonstrating the importance of interfaces. In software development, every decoupling is a big step forward. We opened it with 3 different browsers, and we had the URL of the WebSocket protocol.
First browser: We register a user with test3 with a password of 123 and log in.
The second browser: We use the admin account to log in.
Third browser: No login, tourist status.
We found that logged in accounts can be used to send messages, and then other users can receive messages (tourists can also receive messages)
Send a message and automatically display the other person's nickname, but not the logged-in account.
Finally, let's attach the source code:
Web source code:
Tourists, if you want to see the hidden content of this post, please Reply
Signalr server source code:
Tourists, if you want to see the hidden content of this post, please Reply
|
Previous:.Net/C# 360 ticket grabbing fifth generation VIP line [source code]Next:PowerShell methods for single-line comments, multi-line comments, and block comments
|