What WebSockets Add
What WebSockets Add: What WebSockets Add to HTTP, A First WebSocket Connection.
Updated
- What WebSockets Add to HTTP (Journeyman): HTTP answers only when the client asks, so a page that must hear about a goal the moment it's scored either asks again and again, which is polling, or opens a WebSocket, one connection that stays open so the server can speak first.
- A First WebSocket Connection (Journeyman): The ws package puts a WebSocketServer on the same server and port as an Express app, its connection, message and close events let the server hear from each client and answer it, and the browser's own WebSocket connects a page, with JSON messages whose type says what each one is.