Send and save chat messages over a socket. Create a WebSocket server that sends messages once the WebSocket is connected. WebSockets work in the Chrome browser, so you can use different tabs of the browser to simulate a chat. Alex also explains how to work with the app and test broadcasting messages with a WebSocket.
- [Narrator] In the last lesson, … we started building the socket-server … for our browser-based chat application. … The front-end teams supplied us … is be able to broadcast chat messages. … So, we can send a message to an individual socket … using the socket.send function. … So, when a new socket connects, … I'm going to go ahead and call socket.send … and we'll send a message called welcome to cyber chat. … I'm going to go ahead and save this and open up the terminal, … and the first thing we need to do is run our client, … so we're going to serve the files out of the client folder, … using that serve npm that we installed in the last chapter, … and run our socket-server. … so it looks like we have a connection, … and make sure that it's broadcasted … to every connected socket. … So let's do so, going to come over here and … then you collapse the terminal, … and the first thing I'm going to do is … So we will store any messages for the session … within this array. … The next thing I need to do is listen to message events, …
- 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.