ASP.NET SignalR
SignalR is an Async
signaling library for ASP.NET to help build real-time, multi-user interactive
web applications. ASP.NET SignalR is a library for ASP.NET developers that
makes it incredibly simple to add real-time web functionality to your
applications. What we mean to say "real-time web" functionality? Real-time
web is the ability to have your server-side code push content to the connected
clients as it happens, in real-time.
HTML 5 introduces WebSockets
which enables bi-directional communication between the browser and server.
SignalR uses WebSockets under the cover when it is available and when
WebSockets does not available, SignalR gracefully uses other techniques and technologies
(i.e. Server-Sent Events, Forever Frame etc) while application code stays the
same.
SignalR provides a very simple,
high-level API which calls JavaScript functions in your clients' browsers from
server-side .NET code in your ASP.NET application using Remote Procedure Calls (RPC),
as well as adding useful hooks for connection management, e.g.
connect/disconnect events, grouping connections, authorization.
A Connection represents a simple
endpoint for sending single-recipient, grouped, or broadcast messages. SignalR
handles connection management automatically, and lets you broadcast messages to
all connected clients simultaneously, like a chat room. You can also send
messages to specific clients. The connection between the client and server is
persistent, unlike a classic HTTP connection, which is re-established for each
communication.
The SignalR API contains two models for
communicating between clients and servers:
·
Persistent Connections
·
Hubs.
The Persistent Connection API
(represented in .NET code by the PersistentConnection class) gives the
developer direct access to the low-level communication protocol that SignalR
exposes. Using the Connections communication model will be familiar to developers
who have used connection-based APIs such as Windows Communication Foundation.
A Hub is a
more high-level pipeline built upon the Connection API that allows your client
and server to call methods on each other directly. SignalR handles the dispatching
across machine boundaries as if by magic, allowing clients to call methods on
the server as easily as local methods, and vice versa. Using the Hubs
communication model will be familiar to developers who have used remote
invocation APIs such as .NET Remoting. Using a Hub also allows you to pass
strongly typed parameters to methods, enabling model binding.
SignalR can be used to add any
sort of real-time web functionality to your ASP.NET application. While chat is
often used as an example, you can do a whole lot more. Any time a user
refreshes a web page to see new data, or the page implements Ajax long polling
to retrieve new data, is candidate for using SignalR. It also enables
completely new types of applications, that require high frequency updates from
the server, e.g. real-time gaming.
More about signalR, you may visit
asp.com/signalR
Comments
Post a Comment