Build Real Time Chat Rooms With Node.js And Socket.io

Поделиться
HTML-код
  • Опубликовано: 21 авг 2024

Комментарии • 190

  • @18091991sk
    @18091991sk 5 лет назад +79

    This channel is criminally underrated! We really need to do something to make his videos viral.. Thanks from the bottom of my heart for all the quality content

    • @WebDevSimplified
      @WebDevSimplified  5 лет назад +21

      Thank you! I think I need to sacrifice a goat to the RUclips algorithm gods or something along those lines to go viral 😜

    • @stanislava8650
      @stanislava8650 4 года назад +2

      @@WebDevSimplified Yeah, there is a serious problem with your channel, Kyle. I can't listen to anyone else anymore :)

    • @ankitdutta5240
      @ankitdutta5240 4 года назад

      @@WebDevSimplified can you please help me with uploading this to heroku?

    • @susmitislam1910
      @susmitislam1910 3 года назад

      Idk how many subs you had a year ago but now dear sir you are at nearly 500k subs. Thanks very much for the great tuts and hope your channel grows even more!

  • @ozzyfromspace
    @ozzyfromspace 3 года назад +1

    I didn’t know you could just specify a port and immediately connect 😮. I’ve always created an express server and passed the server object into the socket. Thank you, now I know something new! 🙌🏽✨💯🎊 You the man, Kyle!

  • @sp--nt1gg
    @sp--nt1gg 4 года назад +5

    that's awesome! everyone else is just talking about 20 minutes to explain every detail and it becomes very confusing, but you, just do amazing things that i was looking for months! videos are very short and informative, code is readable because it's pretty formatted, and most important, it's not confusing at all, even for me, i started learning node.js about 3 days ago but i understand! thanks! your channel is too underrated btw... (I shared with all my friends, and even not friends) keep it up man!

  • @akn9699
    @akn9699 4 года назад +2

    I have a request to each and everyone who is following this channel, This guy needs our support and we must spread this channel like an Amazon Wild Fire or even something more. I hope people like Kyle get better exposure. Come on guys, lets push this guy up !

    • @WebDevSimplified
      @WebDevSimplified  4 года назад +1

      Thank you for the support. My channel is already growing at a crazy fast rate in my opinion and I am incredibly thankful for everyone that watches my videos.

    • @akn9699
      @akn9699 4 года назад

      @@WebDevSimplified Great Update, so glad to hear ! Looking forward for more contents....

  • @bawbak8800
    @bawbak8800 5 лет назад +3

    Oh man thnak you so much, the quality of content, voice, code, explanation and everything is awesome.
    Good job man

    • @WebDevSimplified
      @WebDevSimplified  5 лет назад +1

      Thabk you so much. I'm really glad you enjoyed the video.

  • @francohelguera4039
    @francohelguera4039 3 года назад +4

    TypeError: Cannot read property 'emit' of undefined
    if you get this error, in order to fix it, you can delete the .broadcast, is not needed!

  • @JohnWeland
    @JohnWeland 4 года назад +3

    I am really enjoying this. I would love to see a series done to make a discord or slack like system. Even if its just single server. add in mongo for history and user along wit passport of JWT. man it would be rad.

  • @dayanafulla3125
    @dayanafulla3125 5 лет назад +6

    just that i need! thanks for the videos!

    • @WebDevSimplified
      @WebDevSimplified  5 лет назад +1

      You're welcome! I am really glad you found it useful. I had a lot of fun making this video since chat rooms are fun to make.

  • @ManishKarki
    @ManishKarki 5 лет назад +1

    Yay! Just what I asked for. Thank you very much😊

    • @WebDevSimplified
      @WebDevSimplified  5 лет назад

      I hope you enjoyed it.

    • @ManishKarki
      @ManishKarki 5 лет назад

      @@WebDevSimplified You and Dev Ed are two guys who have been very helpful to me. Thank you.

  • @radanmitasik8793
    @radanmitasik8793 5 лет назад

    You and Dev Ed are my top two web dev channels..both so unique creators & teachers

    • @WebDevSimplified
      @WebDevSimplified  5 лет назад

      Thanks! Ed is awesome.

    • @radanmitasik8793
      @radanmitasik8793 5 лет назад

      @@WebDevSimplified So are you ! 😃

    • @tyrrelldavis9919
      @tyrrelldavis9919 5 лет назад +1

      Most overlooked channels on yt tbh, should be as popular as traversy

    • @WebDevSimplified
      @WebDevSimplified  5 лет назад +1

      @@tyrrelldavis9919 Thank you! One day I will be up there with Brad, but he started long before me and is still absolutely killing it with amazing tutorials. I hope to be able to help as many people as he has one day.

  • @SACHIN-gd6zy
    @SACHIN-gd6zy 5 лет назад

    This the best WebSocket Tutorial, hands down man
    You are a Sharp developer
    Tomorrow I am going to buy, your React.js Course without a doubt

    • @WebDevSimplified
      @WebDevSimplified  5 лет назад +1

      Thank you so much! I'm really glad you enjoyed this video and I hope you love the React course.

  • @BruceArmstrong09121997
    @BruceArmstrong09121997 3 года назад +1

    this is an awesome tutorial ,me figuring out Socket.io for a whole day lol
    btw
    i added 2 lines of code
    Reason: Unless the server is restarted , the rooms can be created endlessly with out deleting it after all the users left the room
    socket.on('disconnect', () => {
    getUserRooms(socket).forEach(room => {
    socket.to(room).broadcast.emit('user-disconnected',rooms[room].users[socket.id]);
    delete rooms[room].users[socket.id];
    //the added 2 lines of code
    const roomFull = rooms?.users;
    if (!roomFull) delete rooms[room];
    console.log('user disconnected');
    });
    Hope it helps someone!
    thanks a lot !

  • @ayushmanbt
    @ayushmanbt 5 лет назад +3

    Really awesome tutorial... Loving your tutorials ... Keep it up❤️

  • @Tcatcoder2
    @Tcatcoder2 Год назад

    thank you so much kyle this was my first backend project and I think I want to be a fullstack developer now

  • @liorocker1
    @liorocker1 5 лет назад +1

    How is it possible to build powerful real-time features in only 40 minutes with this 2-part tutorial series, Oh man, this is just amazing, without a doubt your way of teaching makes learning complex stuff a breeze, I really appreciate it.

    • @WebDevSimplified
      @WebDevSimplified  5 лет назад +6

      I am glad you resonate with my teaching style. I try to cut out all the unnecessary fluff and useless information to keep the learning per minute of my videos as high as possible.

    • @sp--nt1gg
      @sp--nt1gg 4 года назад

      @@WebDevSimplified learning per minute xd

  • @JohnWeland
    @JohnWeland 4 года назад +1

    You know building on this and the previous video, adding webRTC for video/audio chat would be neat!

  • @ObulRakhim
    @ObulRakhim Год назад

    great, 5 times I saw it, thanks !!

  • @spiral_memory
    @spiral_memory 3 года назад

    You are great..Such an amazing project.. Explained properly 🎉🎉

  • @_benff
    @_benff 4 года назад

    Thanks a lot for this video and the previous one, very helpful!

  • @jacobross5910
    @jacobross5910 4 года назад +3

    Not sure if I did something wrong, but my 'chat-message' emit was not sending the package to both sender and chat participants, only the participants (username joined the room and chat messages only showing on other clients). So instead of using socket.to(room).broadcast.emit('chat-message') I used io.to(room).emit('chat-message') and it worked.

    • @ahmetkaan2284
      @ahmetkaan2284 2 года назад

      Thank you for your response i have solved my problem related to your comment

  • @maskman4821
    @maskman4821 5 лет назад +1

    This is an awesome project !!!

  • @rahulm5348
    @rahulm5348 4 года назад +1

    thankyou so much for such a good tutorial.
    please make a continuation video on this connecting mongodb database to store user chats

  • @martynas8160
    @martynas8160 4 года назад +2

    Hi , how can I delete chat room that is created ? I would like to know not only how to create but also how to delete the chat room

  • @rajeshwarchennam3096
    @rajeshwarchennam3096 5 лет назад +1

    Thank you so much.. Such a good tutorial

  • @bipulsharma1357
    @bipulsharma1357 3 года назад

    Great content!

  • @artzdesign2352
    @artzdesign2352 5 лет назад +1

    you are great ... more node.js projects .. big one's

    • @WebDevSimplified
      @WebDevSimplified  5 лет назад +3

      I have an entire full stack Node.js course on RUclips if you want a bigger Node.js project.

    • @artzdesign2352
      @artzdesign2352 5 лет назад +1

      @@WebDevSimplified yup , i study it all .. i am asked for another one :)

    • @WebDevSimplified
      @WebDevSimplified  5 лет назад +3

      @@artzdesign2352 I will see what I can do. Thay project took me 3 months to build/record and I am in the middle of a react project right now.

  • @AtopService
    @AtopService Год назад

    Awesome! Would be really nice to know to implement this into a website! Glad it works for you tho!

  • @zlackbiro
    @zlackbiro 4 года назад

    Lool, this is insane... 😁 I created one-time pad encryption library to protect users messages before they goes true the socket.io. Even socket running true the ssl, its still vulerable because government services can decrypt ssl, but my app has power over it and convert message with the ascii dots. 😁

  • @taihatranduc8613
    @taihatranduc8613 3 года назад

    you made a very good tutorial

  • @TheJacex16
    @TheJacex16 5 лет назад +2

    OMG you're the man! I have a question, how would you handle a kick/ban system??

    • @WebDevSimplified
      @WebDevSimplified  5 лет назад +7

      The best way to handle that situation would be to use a database to store users. Then you could also store whether or not the user was banned inside that database as well. One option, if you wanted to ban users from a single room would be storing rooms/users in their own tables and then have a third table that has the id of the user/room they are banned from.

    • @ishaantek
      @ishaantek 3 года назад

      @@WebDevSimplified How do we use a database?

  • @sp--nt1gg
    @sp--nt1gg 4 года назад +1

    why do you still don't have a tick after your channel name?

  • @eddiejaoude
    @eddiejaoude 5 лет назад

    Real-time is awesome 👍

  • @RobertWildling
    @RobertWildling 4 года назад +1

    The "room-created" event needs to check, if it has a "roomContainer" available (which is only on index.ejs), otherwise those, who are in a room, get ugly error messages once a new room is created.
    Third part: Deploy to netlify / zeit / etc?

  • @ikramikky2838
    @ikramikky2838 5 лет назад

    very useful tutorial 🔥💥

  • @kabeerjaffri4015
    @kabeerjaffri4015 4 года назад

    Thank u so much man

  • @Gers217
    @Gers217 3 года назад

    Chat will never be ched again

  • @zlee9288
    @zlee9288 3 года назад +1

    Quick question, how would I get this to save to a database? Mongo to be exact.

  • @sherifsalah5563
    @sherifsalah5563 5 лет назад

    Great, you are awesome 😁

  • @harshagarwal2125
    @harshagarwal2125 4 года назад

    you are amazing

  • @ijazkhan3335
    @ijazkhan3335 4 года назад +1

    Thanks. It was very helpful. Can you extend this with private chat?

    • @WebDevSimplified
      @WebDevSimplified  4 года назад +2

      You can pretty easily. A private chat is just like a room but it is a room that ties directly to another users socket id. The docs for this library have a section on private rooms.

    • @ijazkhan3335
      @ijazkhan3335 4 года назад +1

      @@WebDevSimplified Yeah I also wondered I'll do it that way, but still wanted to be sure... Thanks :)

  • @Hamza-gn2cg
    @Hamza-gn2cg 4 года назад +1

    Thanks so fucking much, you fucking saved me lol

  • @kriann6194
    @kriann6194 4 года назад +4

    tags don't work for me :( help

  • @RollyC197
    @RollyC197 4 года назад

    Great tutorial. Easy to understand. As a new to Node.js and Socket.io, I was looking for chat apps tutorial to use for our website and I think this is the best tutorial I found. I went through and finished it.
    Now, I was trying to embed on our website but sent me '404 Not Found'.
    if I have index.php and want to put a "Chat with us" navigator, how can I do this? I mean how can I link this such as
    Chat With Us ?
    It gives me:
    { %>
    Join
    textbox is here then "New Room"
    Thank you for this tutorial.

  • @irednax
    @irednax 3 года назад +1

    This works locally for me, but when i deploy it to heroku it loads forever and doesn't ask me for my name. How do i fix this?

  • @tabaicanking3701
    @tabaicanking3701 5 лет назад +1

    thanks bro

  • @carljoshuasanchez4828
    @carljoshuasanchez4828 3 года назад

    Great tutorial! Just one question, how can the room be deleted if there are empty users?

  • @difer1412
    @difer1412 3 года назад +1

    I have a question. Do you have any option to delete the created rooms? because these are pilling up. I have made so many in my Heroku app, and I want to delete these. Thank you for the tutorial

  • @mossasameer3338
    @mossasameer3338 4 года назад

    thanks a lot

  • @williamjones0
    @williamjones0 4 года назад +1

    I'm using VS Code too, and have run `npm i express ejs` and they are both in my package.json, but EJS isn't appearing in the languages list, so it's not being formatted properly. Have I forgotten a step or missed something? I have also asked a question on StackOverflow here: stackoverflow.com/questions/59238175/visual-studio-code-isnt-recognising-ejs
    Edit: I have installed the EJS syntax highlighting plugin, but this still doesn't make the language appear in the list.

  • @thanasisathanasi4965
    @thanasisathanasi4965 4 года назад +1

    Hello my friend. What is nodemon used for in your package.json?

  • @MuhammadWaqas-ux1zu
    @MuhammadWaqas-ux1zu 4 года назад

    great video . (y)

  • @Professorjak
    @Professorjak 3 года назад +1

    Hi Kyle, how do we add video chat to the chat rooms?
    Thank you

  • @jasonreviews
    @jasonreviews 5 лет назад +2

    we need encryption part

  • @Naverdo
    @Naverdo 5 лет назад

    Really useful project! Learned a lot from it. Also if I wanted to connect to this site from another device what would i have to do?

    • @WebDevSimplified
      @WebDevSimplified  5 лет назад

      What do you mean?

    • @Naverdo
      @Naverdo 5 лет назад

      @@WebDevSimplified like have the server running and chat app open on my pc and then probably chatting with my friend who is on his pc

    • @WebDevSimplified
      @WebDevSimplified  5 лет назад

      As long as you host the site from this video on a place like heroku you can do that.

    • @Naverdo
      @Naverdo 5 лет назад

      @@WebDevSimplified OK thanks!

    • @Naverdo
      @Naverdo 5 лет назад

      @@WebDevSimplified I've tried to use heroku by myself but just got error after error. Could you do a tutorial on that or point me to a video?

  • @khoahuynh7468
    @khoahuynh7468 4 года назад +1

    can you do the same one with multiple chat rooms?

  • @slimmwillis
    @slimmwillis Год назад

    I am having a problem. I even downloaded from git and still it don't work. On ubuntu. I'm almost sure I did everything hint in the terminal right too.

  • @jonathanalbert920
    @jonathanalbert920 Месяц назад

    can you please create a new project using the latest version of the package ? It changed a lot

  • @mihneaaleman193
    @mihneaaleman193 4 года назад +6

    can you show us how to upload this on heroku?
    if you think this is helpful hit like so kyle can see it

    • @alg2x
      @alg2x 4 года назад

      Mihnea Aleman I can try to help

    • @ankitdutta5240
      @ankitdutta5240 4 года назад

      @@alg2x please help me

    • @ankitdutta5240
      @ankitdutta5240 4 года назад

      @@alg2x I am facing problem uploading the code..can you please help me?

    • @alg2x
      @alg2x 4 года назад

      Ankit Dutta hm sure do u have discord

    • @AnimalUnleashedHD
      @AnimalUnleashedHD 3 года назад

      @@alg2x Can you help me as well? Haha I have a Discord

  • @kamikaze9822
    @kamikaze9822 5 лет назад

    nice video

  • @khadijasworld3899
    @khadijasworld3899 3 года назад +1

    In my project I wanna give the right of creating rooms to a specific client ( in my case I want him to be the professor ) how can I set this condition ? Any help please!! 🙏

    • @francohelguera4039
      @francohelguera4039 3 года назад

      request a password for creating rooms? and just give that pass to the professor

  • @MatteoGauthier
    @MatteoGauthier 5 лет назад +1

    Hey thanks a lot, how can I store the message and display previous messages

    • @WebDevSimplified
      @WebDevSimplified  5 лет назад +3

      You would need to add the messages to a database like MongoDB

  • @maskman4821
    @maskman4821 5 лет назад +1

    Sir, I try to upload this project to glitch.com, but it is not working, the error messages indicates it has to do with https, can you fix the problem???

    • @WebDevSimplified
      @WebDevSimplified  5 лет назад

      It sounds like you need to enable https on the site. I have never used that site so I am not sure.

    • @sp--nt1gg
      @sp--nt1gg 4 года назад

      are you sure you installed socket.io correctly?
      glitch has in-build node.js at projects with "package.json" file.
      you must just go it and click on add package, type socket.io, click on 1st result(install button of 1st result) and you're done now follow video

  • @meteachesprogramming9395
    @meteachesprogramming9395 4 года назад +1

    You should make a part 3 in which you show how to make privatised chat of only 3 people or show how to make them with password.

    • @WebDevSimplified
      @WebDevSimplified  4 года назад

      I'm not sure if I will expand upon this series in particular but I may make a separate chat room series in the future.

    • @meteachesprogramming9395
      @meteachesprogramming9395 4 года назад

      @@WebDevSimplified well ok but its kinda urgent if you have enough time please help me i know that being a youtuber is hard. So if you have time to do a vid please do. Thanks for the reply.

    • @WebDevSimplified
      @WebDevSimplified  4 года назад

      @@meteachesprogramming9395 It won't be something I tackle anytime soon. I am incredibly busy and do not have time for a full project based video like that.

  • @eugenefedorov3498
    @eugenefedorov3498 4 года назад

    Thanks! But how you will make that users who are already in the room will NOT receive socket event when new room is created, as he dont need it.

  • @darthvader4899
    @darthvader4899 3 года назад

    in your rooms object you just store name of the room which is string
    and then you use to(roomName (which is string)) to emit event but how how does it know from just String

  • @mahanthd9915
    @mahanthd9915 4 года назад

    The 1st part of the code works properly but this one is not working please help me out

  • @fidellistaz766
    @fidellistaz766 3 года назад

    Can you make a random chat room system ,like a random chat app

  • @TimeLords910
    @TimeLords910 Год назад

    i need some help i have a problem where devstart is missing as a command to run with the live server

  • @ssumansaha3383
    @ssumansaha3383 4 года назад

    really awesome tutorial .... but i want to delete the rooms after use ...how do that pls help

  • @guygontar6106
    @guygontar6106 3 года назад

    Hi,
    In line 47, when broadcasting 'user-disconnected' event, why the parameter is socket id?

  • @Valnuss
    @Valnuss 4 года назад +1

    I have a question. How do I link stylehseets? I added some and it appears in my source-code. I can open the link via browser and the see code there but it isn't applied to the dom. Is there anything special I use to do? It's lying in the public dir next to script.js

    • @sp--nt1gg
      @sp--nt1gg 4 года назад

    • @sp--nt1gg
      @sp--nt1gg 4 года назад

      FILENAME must be actual filename

  • @Gigabyteserviceofficial
    @Gigabyteserviceofficial Год назад

    you should add a support to mongodb

  • @htmoh8115
    @htmoh8115 Год назад

    Question. If you using websocket, do I still need myphpadmin? I'm new so pardon my ignorance

  • @play4fun181
    @play4fun181 4 года назад

    socket is not working :/ in google chorm but work with other browser. name cant detect keep saying null or undefine

  • @shlokranjan5944
    @shlokranjan5944 3 года назад

    Cannot read property of users of indefined

  • @zizo8737
    @zizo8737 2 года назад

    Please help my browsers are not connecting what to do😢😢😢😢

  • @bogdanivchenko3723
    @bogdanivchenko3723 3 года назад

    I don't know why it doesn't work for me. I have the exact same code. Live server doesn't open .ejs files like html, it opens Listing directory/ where I can see my project filkes. If I click on index.ejs, it just downloads it. I added a .html file into the views folder and it opened it. I tried to open a ejs folder from file explorer and it opened it in firefox but it displayed the script as text. Somebody please help.

  • @amjedallaya9688
    @amjedallaya9688 5 лет назад

    thnx

  • @maheshmahadar4780
    @maheshmahadar4780 3 года назад

    in my website i cant use socket.oi multiple pages.
    is it valid or not i am doing ?

  • @zamankhan1255
    @zamankhan1255 5 лет назад

    please make a video on command prompt

    • @WebDevSimplified
      @WebDevSimplified  5 лет назад

      I have been planning to make a video on basic unix commands, but haven't gotten around to planning it out yet.

  • @user-or7ji5hv8y
    @user-or7ji5hv8y 4 года назад

    How about using a database with an event listener instead of socket.io? Is that a bad idea?

  • @Hogo_-to7tv
    @Hogo_-to7tv 4 года назад +1

    What if I want to make a chrome extension

    • @sp--nt1gg
      @sp--nt1gg 4 года назад

      you came in a wrong place then

  • @kamleshlakhara253
    @kamleshlakhara253 3 года назад

    would you make a video of chat room app using angular and save chat data using php api

  • @trendymasthi7402
    @trendymasthi7402 4 года назад

    How can I escape whitespaces in join link in indez.ejs if room name(ex. Room One) contains whitespaces.
    Join

  • @TheWorldGameGeneral
    @TheWorldGameGeneral 2 года назад

    is this somewhere available in Nestjs?

  • @PawanYadav-yk9ng
    @PawanYadav-yk9ng 3 года назад

    Hello bro, how to limit only two persons in a room.

  • @anurodhyadav1409
    @anurodhyadav1409 4 года назад

    Can you make a video on how to deploy this app in heroku....

  • @therandomsomeone.
    @therandomsomeone. 3 года назад

    i just can't read this code

  • @ishaantek
    @ishaantek 3 года назад

    How can we moderate?

  • @abdullahdanish5329
    @abdullahdanish5329 4 года назад

    hey bro how to implement on online server plzz help how to excute node app.js on online sever

  • @user-fk6dh3yl4e
    @user-fk6dh3yl4e 3 года назад

    the tags do not work. I even tried to download the GitHub files, but they did not run

    • @p0o9i8z
      @p0o9i8z 3 года назад

      Obviously, no one can trouble-shoot your code without seeing it, but if I were to guess, I would say that there are 2 things that are most likely the source of your problem.
      1. Hopefully you noticed that some ( but not all ) of those ejs tags have an equal sign on the left-hand side. One misplaced equal sign is a disaster in the world of ejs. But honestly, if you downloaded the code from Git Hub, and they didn't run either, this is probably not your problem. Because presumably, the Git Hub files would be correct.
      2. Another possibility is outlined in a great article that you can find on the Internet. I will describe it so you will know what to expect. This guy tells you to get a picture of a kitten.jpg so that you can find out which statement you need to use to fix your problems. Then he gives you 3 choices. You try choice 1, and test it with the kitten picture. Then you try choice 2, and test it with the kitten picture. Then you try choice 3, and test it with the kitten picture. For me, choice 3 was the one that worked. You have to put the kitten in a certain folder, and then try each choice, one at a time. The name of the article is: "Serving static files in Express", and you can find it here:
      expressjs.com/en/starter/static-files.html
      By the way, he tells you that you need to use the "path" module, from Node.js, but he never tells you to "require" the path Module. Without "path", choice 3 ( which I mentioned above ) will never work.

  • @mohammedsayeed330
    @mohammedsayeed330 3 года назад

    Shared Your channel link to my frirends..but please kindly add css to this app

  • @seanwei4025
    @seanwei4025 4 года назад +1

    you are so handsome......

  • @REBELxLOPEZ
    @REBELxLOPEZ 4 года назад

    Can these be converted to React?

  • @otepiii
    @otepiii 4 года назад

    how can I add this to my website?

  • @mahanthd9915
    @mahanthd9915 4 года назад

    I'm using visual studio code when i run the code its giving me an error .

    • @sp--nt1gg
      @sp--nt1gg 4 года назад

      what error is this

  • @dinero474
    @dinero474 4 года назад

    it would be cool if you made something like omegle. Users connect to a random generated a room and only 2 users can connect

  • @vampirejs758
    @vampirejs758 3 года назад

    How can I host this app

  • @anurodhyadav1409
    @anurodhyadav1409 4 года назад

    How do i deploy this application??

  • @Nanda-ho5eh
    @Nanda-ho5eh 3 года назад

    Can anyone suggest a way to add a databse to this chat app