Chapter 6. Exemplifying Real-Time Web Functionality
No web user wants to hit refresh constantly for the latest information. They want everything right now, automatically. Real-time web functionality is very common, and most modern apps require it. Many apps rely on live data to provide pertinent information to their users as soon as it becomes available. In this chapter, you’ll learn how to implement real-time web functionality using ASP.NET Core SignalR (or just SignalR). You’ll then find out how to create a server-side (Hub) that will expose many live data points, such as real-time alerts and notifications, a messaging system for live-user interactions, and a joinable active Twitter stream. Finally, you’ll learn how to consume this data from our Blazor WebAssembly app, which will respond to and interact with these live data points in compelling ways.
Defining the Server-Side Events
For your Blazor app to have real-time web functionalities, you need a way for it to receive live data. That’s where SignalR comes in. Real-time browser-to-server protocols such as WebSockets or Server-Side Events can be complex to implement. SignalR provides an abstraction layer over these protocols and reduces the complexity with a succinct API. To handle the many clients to a single server, SignalR introduces the hub as a proxy between the clients and the server. In a hub, you define methods that can be called directly from clients. Likewise, the server can call methods on any of the connected ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access