liveBook · Manning

Chapter 4: Adding order-tracking functionality with SignalR

What you will learn in chapter 4 of Building Distributed Applications that Work

The chapter introduces a delivery-tracking app whose map updates automatically as a driver moves, and identifies the two capabilities needed to build it.

After this chapter you will be able to

What it builds on

Section by section

Introduction

The chapter introduces a delivery-tracking app whose map updates automatically as a driver moves, and identifies the two capabilities needed to build it.

Key terms: delivery-tracking app, driver’s coordinates, marker, SignalR, OpenLayers, real-time communication, interactive map

4.1 What is SignalR?

This section explains how SignalR provides real-time client–server communication, abstracts its transport through hubs, and supports updates across multiple servers.

Key terms: SignalR, real-time, bidirectional communication, push updates, WebSocket, server-sent events, long polling, transport mechanism, hubs, remote procedure calls (RPCs)

4.2 Introduction to OpenLayers

This section introduces OpenLayers as the browser-based mapping library for the order-tracking UI and describes the geographic data it can display.

Key terms: OpenLayers, interactive maps, geographic data, vector, raster, layers

4.3 Building a delivery-tracking system

The section identifies the delivery-tracking backend’s responsibilities and clarifies that the example assumes an order has already been placed.

Key terms: OnlineShop.ApiService, SignalR hub, location updates, Aspire integration, business logic, order-processing workflow

4.3.1 Setting up a SignalR hub

This section explains how the backend SignalR hub accepts delivery-driver coordinates and broadcasts them to connected clients.

Key terms: OnlineShop.ApiService, SignalR, ASP.NET Core SDK, NuGet dependencies, LocationHub, Hub, UpdateLocation(), latitude, longitude, SendAsync()

4.3.2 Registering a SignalR hub

The section explains how to register the SignalR hub and give it a recognizable HTTP endpoint.

Key terms: Program.cs, OnlineShop.ApiService, SignalR dependencies, HTTP endpoint, app.Run(), /locationHub

4.3.3 Simulating location updates

The section shows how a background service simulates delivery-driver movements and sends location updates to connected SignalR clients.

Key terms: IHubContext, LocationHub, Clients property, LocationUpdater, background service, location updates

4.4 Building the frontend map UI

This section sets up the frontend SignalR client and describes JavaScript that displays an OpenLayers map and replaces its delivery-location marker as coordinates arrive.

Key terms: OnlineShop.Web, Microsoft.AspNetCore.SignalR.Client, NuGet package, site.js, OpenLayers, ol, Map(), OSM, view, location marker

4.4.1 Registering frontend dependencies

This section prepares the Blazor frontend for a map by registering its JavaScript and CSS dependencies and enabling interactive rendering.

Key terms: App.razor, OpenLayers, content delivery network (CDN), head tag, body tag, _framework/blazor.web.js, static server rendering, interactive render mode, HeadOutlet, Routes

4.4.2 Building the interactive UI

Builds a Blazor order-tracking page that connects to an Aspire-hosted SignalR hub and displays location updates on an interactive map.

Key terms: IHttpMessageHandlerFactory, HttpMessageHandlerFactory, WithUrl(), apiservice, service discovery, life-cycle event method, static server-side rendering mode, initializeMap, StartAsync(), IJSRuntime

4.5 Summary

Where this is used later

Concepts explained in this chapter

← Chapter 3: Using database and storage components Chapter 5: Building a ChatGPT clone with Aspire, Ollama, and Semantic Kernel →

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.