How To Create Real-Time Applications With SignalR On Windows
History on Client-Server Apps When the original web first came into widespread public use things were reasonably basic. Webpages were effectively specialized documents, like a library. Users clicked on links to articles they found interesting. Somewhere, perhaps on another side of the world, another computer or server was the destination for that click or as we came to call it: the request. The user sends a request and, the server, the far-off computer, gives a response back to the user for every request. That response was typically formatted text, images and later, movies and music. Editing web pages was done mostly using plain text editors rather than more advanced ide software. After several years and a few iterations, Web 2.0 emerged allowing a more interactive, programmable kind of web page which behaved more like an application. The process was asynchronous and, we were able to execute commands on databases and manipulate the data they contained in that way. Like, create a user, get all users and delete a user. With the advent of Web 3.0 and beyond, a new concept applied to the systems is a continuous connection between a client and a server. Web applications could now carry out significantly complex tasks, interact with specialized hardware like GPS sensors and other activities rivaling traditional desktop application capabilities. Along with this rose the need to implement real-time connections which transmitted data between the web browser and servers in an optimized and highly efficient way. The connection between the server and client can be used on either side to update and set the state and react accordingly. We refer to that highly interactive nature as “real-time web applications”. They’re a long way from those original electronic reference type documents of the original web. What methods are there for implementing real-time web applications? Interval polling This method is very straightforward. We go to the server and see if we have anything we need to do in the interval. And there are 3 cases: Nothing will be returned The server has data that return to us Some sort of internal server error But no matter what, we go to the server to see if we can do anything. Problems of interval polling More connections, more overhead Mode bandwidth The server can’t keep up with the request Long polling As you can see, we were making requests every 10 seconds no matter what. Long polling is a call that we open up and remains open until the server has something for us (depending on browser timeouts). And after a timeout, we open up our request all over again. Benefits of this method: Less server overhead and resource consumption The downside is we still make and open connections regularly. Server-Sent Events In this method, we open a connection to the server and, that server can remain open indefinitely. And server makes use of this connection or pipe to send us messages. The best thing about this is the server can push data to the browser without requiring multiple connections. But this is one way in which the client cannot send messages to the server. Web Sockets Web sockets are the ability of the client in the server to open a one-on-one connection, which they both can send data over. What are the benefits of Web Sockets? Bi-directional communication […]
