A great benefit of working with Socket.IO is that you can raise for events by name. The traditional WebSocket spec can only listen for message events. Raising events by name allows you to create more advanced socket applications. In this video, create a custom chat event and broadcast it to all connected sockets.
- [Instructor] In the last lesson … So another benefit of using socketIO … is its ability to raise events by name. … This means that all types of data have … to be passed through the same event. … It would take us a lot of code to separate chat rooms … SocketIO allows us to listen to and emit events by name. … That makes it a bit easier for us to build larger … and more complected socket applications. … So we didn't handle the chat functionality … So I have the socket server.js file open … So we can listen for a custom events by name. … I'm going to call this event chat. … So whenever a chat event is emitted, … So we're going to log it by using the socket.id … so we can know which socket sent this message … to every socket by using io.sockets. … And I can emit events by name too. … So the next thing I need to do is pass the message. … That's the third argument … and I'm going to pass the socket.id as well. … Great, so when any of our sockets emit a chat event, … we will go ahead and log the socket.id …
- 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.