WebSocket begins with an HTTP upgrade handshake. Once accepted, client and server exchange messages in both directions on the open connection.
The demo alternates message direction after the upgrade. Real-time applications must still handle authentication, connection lifetime, and reconnection.
When to use
Consider it for chat or collaboration when both sides frequently initiate messages.