SignalR Traits

Preface

  • This article focuses on important traits of SignalR
  • I hope that after reading this article you will get good start for SignalR implementation
  • In earlier ASP.Net web applications, user need to manually refresh a web page to see new data changes from server, it uses timer based “long polling” to retrieve changed data, i.e., when new data arrives to server it will not be directly transmitted to all clients or specific clients, for that the user has to refresh the page, and the page will be updated. This article will focus what, why and how of SignalR

What is SignalR

  • SignalR is library for creating real-time communication applications between servers and client (web browsers)
  • Real Time web communication is the ability to have server code to push contents to connected clients
  • SignalR supports server push or broadcasting functionality implementation

Why SignalR

  • SignalR provides real time persistent communication over traditional long polling request response
  • It leverages HTML 5 based web sockets for transport; SignalR reduces the complexity of WebSocket to the point that a connection can be opened and used with just a few lines of code
  • SignalR support inbuilt fail over support for following transport ( fail over means if one transport is not supported by client then it will switch to next available transport )
  1.  Web Sockets ( Requires Windows 8 and .NET Framework 4.5 )
  2.  Forever Frame
  3.  ServerSentEvents
  4.  LongPolling

How to use SignalR

SignalR provides two models for communication:

  • Persistent Connections

The Persistent Connection API gives developer direct access to the low level  communication protocol that SignalR exposes. This API uses the format of the actual message sent that needs to be specified and if the developer prefers to work with messaging and dispatching model rather than a remote invocation.

  • Hubs:

It’s a High Level API written over PersistentConnection. This API allows the client and server to call methods on each other directly. Hubs also allow you to pass strongly typed parameters to methods, enabling model binding.

You can refer following high level representation of SignalR communication

  • Client 2 sends data to server and immediately it is available to Client 1, Client 3

SignalR

Please refer following to setup SignalR in ASP.Net

Where to use SignalR

  • Chat applications
  • Real time applications for data

Reference

 

Leave a Comment

Your email address will not be published. Required fields are marked *