A First WebSocket Connection

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.

By

Updated

Cheat sheet: A First WebSocket Connection
Category
Node.js
Level
Journeyman
Tags
Event Listener, JSON.parse(), nodejs, Static Files in Express, web-development, WebSocket (web-development), ws