Skip to main content

WebSocket Push vs. Polling

This example is the first screen of TicketOps Live. A live status strip (statusPanel, clockLabel, connectionLabel, activityLabel, serverLoadBar, startButton, stopButton) driven by a simulated server heartbeat, plus the in-request Refresh, the 5-step server event pushed with Application.Update(this), and an update trace.

Run it

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

Then open http://localhost:5301. (Visual Studio: open TicketOpsLive.slnx, press F5.)

What to try

ControlWhat you should see
RefreshstatusLabel shows "Refreshed at …" — the change comes back with the click's response (no Application.Update)
Start server eventpushStatusLabel goes step 1/5completed, 600 ms apart, with no further clicks
▶ Start heartbeatonce per second: clock, load bar and Heartbeat #n are pushed; the button stays disabled while running
■ Stopthe loop ends within one second and Start is enabled again
Update traceone line per request and per pushed step

Polling fallback. Add "enableWebSocket": false to Default.json and restart: connectionLabel shows "No WebSocket — polling every second" while a task runs, the browser console shows one Wisej: Poll request. per second, and the heartbeat still arrives (about a second late). Polling is requested when a task starts without a WebSocket, not in MainPage_Load (IsWebSocket is still false during Load), and ended when the task finishes.