WebSockets: A Live Wire to the Backend

HTTP can't watch a dog walk

Everything the app has done so far is ask once, answer once: URLSession sends a request, the backend replies, the connection is done. That shape is wrong for live tracking β€” the walker's phone produces a new GPS position whenever it moves, and the owner's phone should see each one the moment it happens. Asking GET /position once a second (called polling) is wasteful and always a beat behind.

A WebSocket fixes this. The app makes one special HTTP request that says "let's keep this connection open", the server agrees, and from then on either side can send a message at any time, for as long as the connection lives. If plain HTTP is mailing letters, a WebSocket is a phone call.

PawWalk opens one WebSocket per booking. The walker's phone sends GPS fixes up the wire; every phone watching that booking receives them. The whole client lives in one file β€” Services/LiveTracker.swift β€” and this module takes it apart piece by piece.