Introduction on SignalR
Real–Time Web Application
The real-time web is a set of technologies that enable users to receive information as soon as it is published by its authors, rather than requiring that they or their software check a source periodically for updates.
Examples of Real–Time Web Application Development
- News feed and Notifications in Facebook
- New updates in Twitter
- Google Search
- Google Docs
History of ASP.NET SignalR
Damian Edwards (a program manager on the Microsoft ASP.NET team) was motivated to build a solution for this common problem on Microsoft technologies. SignalR was the answer that started as an open-source project and attracted some other developers as well. Later on, David Fowler (software developer on the Microsoft ASP.NET team) took a serious role in developing this project and has continued to do so.
What Is ASP.NET SignalR?
SignalR is a library on top of the .NET Framework and jQuery (or other client-side technologies) to create real–time web applications by providing application programming interfaces (APIs) that are ready to be used out of the box.
Architecture
Transport Options
SignalR relies on transport layers to make communication possible between client(s) and server(s). These four transport layers are categorized in two groups: Comet approaches and modern HTML5 approaches.
- Long Polling
- Forever Frame
- Server-Sent Event
- WebSockets
How ASP.NET SignalR Uses Transports
The ASP.NET SignalR JavaScript library has a built-in mechanism that switches between approaches in priority based on their availability. Unless you specify one or more transport options to be used, the following order of options is considered:
- WebSockets
- Server-sent event
- Forever Frame
- Long polling
Creating a sample SignalR Application
1. Create a new ASP.NET MVC Web Application using Visual Studio.
2. Add SignalR libraries using the NuGet Package Manager.
3. Click on Install which downloads and adds the required SignalR libraries into the project.
4. After the assemblies are installed, you have to create an endpoint. Create a folder called PersistentConnections.
5. Add a class called SamplePersistentConnection.cs in the PersistentConnections folder. Add the code into the class as below.
6. Add Startup.cs class if it is missing in the project and update the code as below.
7. Add index.html page to the project.
8. Add the below code to the head section of the html page.
9. Add the below code to the body section of the html page
.
10. Open two instances of the browser and browse for the application. The message sent is immediately available to all the clients.
References
2. http://www.codeproject.com/Tips/590660/Introduction-to-SignalR
3. http://www.c-sharpcorner.com/UploadFile/82b980/introduction-to-signal-r/