Resources:
This lesson will discuss the natural progression from HTTP to WebSockets. It should cover topics such as the Upgrade
header, the client/server handshake, transfer of data, and connection persistance. All of these concepts and more are covered in the MDN documentation. Security should also be covered in this lesson
This lesson will discuss possible application designs utilizing the WebSocket protocol. It should share things like broadcasting, client -> server, server -> client, and then explore actual application examples such as messaging, multiplayer games, and monitoring dashboards.
While teaching different use case scenarios, it may be valuable to show how these same applications would suffer if limited to just HTTP (for example, if you had to build a chat app using only REST, clients would have to routinely ping the server for new messages rather than being able to be broadcasted too).
The quiz for module 1 should reinforce the conceptual aspects of WebSockets. Students should be able to demonstrate their understanding of the WebSockets protocol, and conceptualize potential project ideas with it.
This article on Implementing a WebSocket Server using Node.js would serve useful for folks who like to deep dive into implementing things from scratch. May be worth rewriting with modern Node apis though since it was published in 2018.
The second module will focus completely on using the popular ws
module for building JavaScript applications with the WebSockets protocol.
There are some great usage examples provided by the ws
docs. This lessons should cover these examples and feature getting started content such as installing and initializing the module.
This lesson/project should show the student how to build a trivial chat application using the ws
module. This application should be as simple as possible to focus strictly on the WebSocket protocol. The student should not be responsible for implementing DOM mutation logic, but should learn how to correctly wire up a WebSocket client for the front end part of the app.