Skip to main content

From One Session to Many

The ticket simulation is refactored into a global TicketHub: a thread-safe singleton that owns the shared ticket list and raises TicketChanged. Every browser session loads a snapshot, subscribes, filters by its own tenant and updates its own bound list and notification panel in its own context.

Run it

cd "LearnWisej-Samples/Real-Time Server Push Course/Module 6/TicketOpsLive"
dotnet run -f net10.0 --urls http://localhost:5306

Then open http://localhost:5306 in two or three tabs — every tab is a separate session talking to the same hub.

What to try

  1. Tabs A and B on Contoso, tab C on Northwind (the Tenant combo).
  2. In tab A select a row and click Publish Event: A and B update (B with no click at all); C shows nothing.
  3. In tab C click Publish Event with no row selected: a new Northwind ticket appears in C only.
  4. Select a row and click Escalate selected: every session of that tenant updates the row and shows a toast. Added/Updated events never pop a toast — that is the event-type filter.
  5. Click Unsubscribe in tab B: publishes from the other tabs no longer reach it. Subscribe brings it back.
  6. Close tab B: its session ends, ApplicationExit unsubscribes it, and the other tabs keep working.

notificationCountLabel counts what this session received (the extension challenge), even though every event comes from the same global service.