WebSockets are a native part of the HTML5 spec. WebSockets allow for a two-way connection between the client and the server. Alex Banks explains how WebSockets work and describes their protocol. In this video, install the ws module, which allows you to create WebSockets and then start to build a WebSocket to handle a chat application.
for a true two-way connection … between a client and a server. … Clients can connect to a socket server … until that client disconnects. … chapter four lesson one, … and within the start folder, … that contains the client files for a chat application. … so we can take a look. … All right, so here's our chat app, … Let's see what that is all about. … is trying to make a WebSockets connection … to ws local host 3000. … that we'll use to help us construct a WebSocket. … We're going to create an instance of the WebSocket server, … So I can handle a connection event … by wiring up in on connection. … So when this socket emits a close event, … Great, so that handles connections and disconnections … from WebSockets. … So we go ahead and just add a console.log down here … So let's go ahead and try out our page now. … is every time I open another window, … So now I have three tabs open to my chat application. … That means that three sockets have connected. … So these are individual two-way connections …
- Making HTTP requests
- Building web and file servers
- Installing packages with npm
- Managing and linking global packages
- Working with Express, the web server framework
- Handling POST and DELETE requests
- Creating WebSockets
- Testing and debugging Node.js code
Skill Level Advanced
Node.js: Real-Time Web with Socket.IOwith Emmanuel Henri1h 24m Intermediate
Work with VSCode1m 59s
1. The HTTP Module
3. Web Servers
5. Node.js Testing
6. Automation and Deployment
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.