fbpx

Made in USA: Enterprise Application Services

Ringing PhoneCall Today!817-210-4042

Real Time Web with SignalR and Comet

Real Time Web with SignalR and Comet

April 17, 2014
|
0 Comments
|

SignalR provides API for building real time web functionality in the ASP.NET applications. Real Time web functionality is the ability to have server side code push content to the connected clients as it happens in real time.

The most common examples of real time web applications are Facebook’s news feed and Twitter, or features like chat and search, where the user gets the notification in the browser’s document window as the event happens in the form of a message, alert, update, or link to an article with decreased server load time.

signalr, websocket

To do this, SignalR must take advantage of HTML5s API that includes WebSocket, which takes an advantage of several packet transports by automatically selecting the best available transport given the client and server’s best available transport. When the technology isn’t available, it will gracefully fall back to other techniques, making sure the application code remains the same. SignalR will use HTML5 to transport WebSockets, utilizing its bi-directional communication line between the client and the server with server-to-client RPC (Remote Procedure Call). The RPC allows an inter-process communication line to be opened and lets the code call a subroutine to be executed from a different client remotely without the developer having to execute the subroutine from a specific location or compromise load time. Unfortunately for the outdated client, WebSocket is only available in later versions of Internet Explorer, Google Chrome, and Firefox, with partial implementation ability on Safari and Opera. SignalR provides this RPC that call the JavaScript functions from .NET code on the client side. It also provides an API for connection management for grouping connections or connect and disconnect events. It starts out first as an HTTP, and is then promoted to a WebSocket if the bandwidth is available. WebSocket is the best use of (the small amount of) memory that will be allocated.

In comparison, the Comet web application model will support an HTTP request that is held open for a long period of time during which time the server can send data to the client without the client knowing it may need to request it. For Internet Explorer, the Forever Frame, which creates a hidden iFrame that opens a connection that acts as a one-way connection from the server to the client. To get back the other way, from client back to server, a standard HTML request is posted and a new connection must be created per data packet to be sent. For other browsers, Ajax is implemented to poll the server with a request that stays open until the server responds and closes the connection, instantiating a request to open another connection.

Monitoring how your packets are transported can positively or negatively impact your code reception by users accessing and using your real-time web environments through browsers. The most successful real-time web environments were able to adeptly anticipate and implement their users’ propensities and seamlessly integrate those practices to create a true real-time web environment that can be accessed from anywhere with any device.

Related Posts