Recall & Review
beginner
What is a WebSocket server?
A WebSocket server allows real-time, two-way communication between a client and server over a single, long-lived connection.
Click to reveal answer
beginner
Which Node.js package is commonly used to add WebSocket support to an Express server?
The 'ws' package is commonly used to add WebSocket support to an Express server.
Click to reveal answer
intermediate
How do you create a WebSocket server that works alongside an Express app?
You create an HTTP server from the Express app, then attach the WebSocket server to that HTTP server.
Click to reveal answer
beginner
What event do you listen for to handle new WebSocket connections?
You listen for the 'connection' event on the WebSocket server to handle new client connections.
Click to reveal answer
intermediate
Why is it important to handle errors and close events on WebSocket connections?
Handling errors and close events helps keep the server stable and frees resources when clients disconnect.
Click to reveal answer
Which method creates an HTTP server from an Express app to use with WebSocket?
✗ Incorrect
You use Node's http.createServer(app) to create an HTTP server from the Express app.
Which event do you listen to on a WebSocket server to accept new clients?
✗ Incorrect
The 'connection' event fires when a new client connects to the WebSocket server.
What package do you install to add WebSocket support in an Express app?
✗ Incorrect
The 'ws' package is a popular lightweight WebSocket library for Node.js.
How do you send a message to a connected WebSocket client?
✗ Incorrect
You use the send() method on the WebSocket client to send data.
Why should you handle the 'close' event on a WebSocket connection?
✗ Incorrect
Handling 'close' lets you clean up resources when a client disconnects.
Explain the steps to set up a WebSocket server alongside an Express app.
Think about how Express and WebSocket share the same HTTP server.
You got /5 concepts.
Describe why WebSocket is useful compared to regular HTTP requests.
Imagine chatting live versus sending letters.
You got /4 concepts.