Signal
r is a new developer’s API provided
for ASP.NET web applications, used to add "real time"
web functionality to ASP.NET applications. "Real Time" web
functionality is the ability to have server code to push contents to connected
clients.
SignalR supports "server
push" or "broadcasting" functionality. It handles connection
management automatically. In classic HTTP connections for client-server
communication connection is re-established for each request, but SignalR
provides persistent connection between the client and the server.SignalR is an open-source API, and is accessible
through GitHub.
Where to use:
·
Chat room applications
·
Real-time monitoring applications
·
Job progress updates
·
Gaming applications
What technologies does SignalR use to transfer data?
·
Using WebSockets if it is available
·
Otherwise, using other technologies, e.g. long polling,Server Sent Events ,Forever Frames
What kind of data does SignalR support to transfer?
- Non-compressed JSON
text or plain textIf you want to transfer compressed JSON or BSON or your
binary data, you have to encodeusing Base64) or to
- Implement IJsonSerializer by your own logic on
the server side and implement the same logic on the client side. Note that TextReader and TextWriter are used inside
SignalR. That means you have to convert your data to text before
transferring anyway.
API
Details:
SignalR provides two models for
communication:
1. 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.
2. 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.
Figure:
chat application process
Web Sockets:
They allow a long-held single TCP socket connection to be
established between the client and server which allows for bi-directional, full
duplex, messages to be instantly distributed with little overhead resulting in
a very low latency(no delay) connection.
Both the WebSocket API and the WebSocket protocol are standardised which means the web now
has an agreed standard for realtime communication between Internet clients and
servers.
References:
http://www.codeproject.com/Articles/524066/SignalR-Simple-Chat-Application-in-Csharp
http://ruwandotnet.wordpress.com/2012/03/17/74/