Monday, December 4, 2017

Asp.net Real-time application with SignalR

Overview:

Real-time applications are that applications that display data to the connected user as soon as it becomes available.  Facebook and twitter and online multiple player games are the great examples of  real-time applications.

Introduction to SignalR:

Microsoft introduced SignalR Library for Asp.net developers to build Real-time applications. SignalR has an ability to push content from the server on all connected user intently and user won't need to refresh the page for updates. SignalR uses four different transport medium to simplify the process of real-time communication.
  1. WebSocket.
  2. Server Sent Events
  3. Forever Frame
  4. Ajax Long Polling
SignalR checks the best available transport on connected client, it first checks the WebSocket transport on client and use this technology. If client does not support it repeats the same process for the next available transport.
SignalR consists of to different connection models that makes the client-server communication possible in two different ways.
  1. Persistence Connections.
  2. Hubs.

Persistence Connection.

Its a low-level connection allows more control over the connection, user can extend  PersistenceConnection Class  to perform more specific tasks.

Hubs.

Hubs are the high-level connection over persistence connection, that are most preferable among users. it allow user to call service side methods from client side and vice-versa .

SignalR Implementation.

Following are the steps to implement a simple notification system with SignalR in Visual Studio and C#.

Building a simple Notification System.

In this demo, user will need to enter their PIN to login, once the user is logged in, Admin user will be notified and get this user in Active User list.
Step # 1: Create Project. 
Create a new C# Asp.net Web Form Application and give a name "SignalRNotificationDemo".