Socket IO Rooms Tutorial (Backend part 1)

Поділитися
Вставка
  • Опубліковано 30 вер 2024
  • Get 1 on 1 mentorship with me! ▶▶▶calendly.com/c...
    In this video I demonstrate the usage of socket io rooms. Socket io rooms, allows us to create separate channels which sockets can join, and send messages to. This allows us to create more fully feature chat applications similar to slack which have the ability to join multiple channels as well as allows us to send direct messages to other users.

КОМЕНТАРІ • 97

  • @thelitterateman
    @thelitterateman 3 роки тому +12

    slow down bruhh. M here to learn, but you're on a train.

    • @eloy_777
      @eloy_777 3 роки тому +1

      You can just watch it slowed to x0.75, the video won't be that longer

  • @VamsiKrishna-yt5hi
    @VamsiKrishna-yt5hi 3 роки тому +9

    I think it is not safe for the server to call a function passed by a client. That function could be anything. Moreover, you are revealing to the client that you are using a Javascript backend.

  • @atticus2581
    @atticus2581 2 роки тому +5

    Damn, ussualy i speed these things up and had to check I hadnt increased playback speed, this guy talks fast! I like it!

  • @ЖукОбычниик
    @ЖукОбычниик 3 роки тому +5

    I don't agree with you passing a callback function from the clinet side this is literally the most dangerous thing you can do because hackers

    • @ЖукОбычниик
      @ЖукОбычниик 3 роки тому

      @Amir Moeen Rahmani well you see whet he does is he gets a function from the user and executes it on the backend but the user can put whatever malicious code he want in that function with that the hacker can: crash your backend, make a never ending loop preventing the backend from functioning properly, steal all the data he wants, and the list goes on. This dude is legit letting anyone send a function to the backend that will get executed even I with 0 hacking skills could crash his backend

    • @CodingWithChaim
      @CodingWithChaim  3 роки тому

      This is the docs from socket.io talking about this approach. socket.io/docs/v3/emitting-events/
      Scroll down to Acknowledgements
      I should also mention that there is no risk here because this is not code that executes user code. A good example where one more worry about executing user code is with the common xss attack. For example, you have a blog, and then you have comments, now a user can make a comment have a script tag and then add their own javascript to this script which will execute on your website. This works because when you render a script tag, the code within executes.
      In this case however, you are not taking user entered data and passing it along to an environment that can execute this code.
      Hope this helps clear things up.

    • @ЖукОбычниик
      @ЖукОбычниик 3 роки тому +1

      @@CodingWithChaim But can I not write a regular node script that will connect to the server and emit an event with the malicious function?

    • @mindglimpse559
      @mindglimpse559 26 днів тому

      @@ЖукОбычниик When the server executes the callback provided by the client, it is essentially sending a message back to the client that triggers the client's function. The server does not run the client's code directly.

  • @thegoodgolly1465
    @thegoodgolly1465 3 роки тому +11

    Seriously appreciate this. Idk if you're just on my wavelength but this makes the most sense out of the socket IO and rooms tutorials I've seen so far. You quickly and perfectly explain what you're doing and why you're doing it without going overboard, and even though I'm working on an app that's not the same as the chat you make in this tutorial, I'm actually able to follow along and pick out or edit as needed without losing functionality.

  • @mentalmodels5
    @mentalmodels5 3 роки тому +5

    10:16 wouldn't that be insecure? Since people can modify the client javascript and execute another function?

    • @williamduncan7401
      @williamduncan7401 3 роки тому

      if your function is e.g. `console.log` this will not trigger `console.log` on the server, just on the client. it's literally like emitting a response back containing the function name and arguments and the client calling the function, but it's a built-in thing to save you that client-side code

  • @number1neek
    @number1neek 3 роки тому +4

    Thanks for the video. Really well explained!
    One bit of constructive criticism though - I like the fast pace but at times it sounds like you're rushing and some words are hard to understand. I had to check I didn't have you set to 1.5x speed lol

  • @christianangelomsulit3759
    @christianangelomsulit3759 3 роки тому +2

    Set speed to 0.75 and everything for me is now clear

  • @serjio8781
    @serjio8781 3 роки тому +7

    You've totally nailed this socket io stuff! Looking forward to the client side part :)

    • @CodingWithChaim
      @CodingWithChaim  3 роки тому +2

      Thank you! Well I certainly hope the client side part won’t disappoint

  • @nom21304
    @nom21304 3 роки тому +3

    imagine him rapping :o

  • @ozzyfromspace
    @ozzyfromspace 3 роки тому +3

    Hey Chaim! This was a magnificent video, thank you so much for putting this beauty together! 🏆🎊🙌🏽
    I'd like to voice an educated guess: the client-side defined callback may be a security risk. I'm thinking that a highly motivated attacker could reverse engineer your build js file and alter the callback to do something malicious, and it will run on your server regardless. That's my immediate thought, but I'll have to watch the next video to see how you do the cb. I read it in the docs a few weeks ago but I didn't understand it then. Do you have an opinion on this?
    Again, phenomenal explanation of the "rooms" concept! 💯😎

  • @tahsinalmahi8769
    @tahsinalmahi8769 10 місяців тому +1

    Great tutorial. Thanks a lot!

  • @p_o_z_e
    @p_o_z_e 8 місяців тому +1

    This is still such a good video, super useful.

  • @kumar_sanjeevdutta1069
    @kumar_sanjeevdutta1069 8 місяців тому

    Really great, but you speak too fast, I am native Hindi speaker and thank God UA-cam has this slow video speed feature 🙏🙏

  • @princeanujk
    @princeanujk 3 роки тому +1

    Amazing Content...💕
    Just Watch @ 0.75x Playback Speed...

  • @ikibkilam8383
    @ikibkilam8383 3 роки тому +1

    Very cool! Thank you for doing these videos. Btw, I think the link to the code repository for this video is not correct.

  • @_MoshikoAz_
    @_MoshikoAz_ Рік тому

    thank you Chaim, can you please provide git source ?

  • @chriscalver8595
    @chriscalver8595 21 день тому

    That was awesome. Love that you speak fast.

  • @Whitetail
    @Whitetail 3 роки тому +1

    Thank you very much. This is an amazing tutorial, very well explained. You helped me save a lot of time.

  • @deeperealms
    @deeperealms 3 роки тому +1

    Really awesome tutorial!
    I am kind of concerned about the security of letting the client send a callback function to run on the server though. I've just been getting deeper into security, so maybe I'm paranoid, but it seems very vulnerable to some sort of code injection?

  • @ivaylosilovski5529
    @ivaylosilovski5529 3 роки тому +3

    Great content! Keep it on going :)

  • @softultraviolence5673
    @softultraviolence5673 2 роки тому

    great video! But man, you sound like a texan auctioneer

  • @MrPoppshot
    @MrPoppshot 2 місяці тому

    I thought my video was on 2x speed.

  • @x4r7
    @x4r7 2 роки тому

    this is the first video where i need to slow down to 0.75

  • @ikoLinh
    @ikoLinh Рік тому

    hablas rapidísimo, pensé que sabia ingles😅

  • @shreyanmehta6999
    @shreyanmehta6999 2 роки тому

    didnt needed to make its speed faster

  • @jcfiedalan8172
    @jcfiedalan8172 3 роки тому

    You can beat Eminem :)

  • @gurkanucar
    @gurkanucar 2 роки тому

    Thanks a lot! By the way, cb(callback) is equal to ack. It may cause confusion because I am applying this in the java spring boot application and I couldn't find anything about the callback. So just i wanted to mention it. Thank you again :)))

  • @sashaikevich
    @sashaikevich Рік тому

    1337. What a throwback ! Great pace for your vid. What do you do when you’re not making UA-cam vids, got a blog or something I can read?

  • @oyerindejoshua9365
    @oyerindejoshua9365 2 роки тому

    pls where is the part two

  • @zoksss5323
    @zoksss5323 2 роки тому

    I have a question. So basically, when user joins, you push its username and id to usernames array, which contains all users. But what happen if user leaves and his info still stays in array? I'm doing something simmilar with pushing room code which is a object with few details and users insde that room eg.
    "123" = {leaderId: "", isLocked: false, sockets: []}
    , but when all users leave, i want to destroy that room object, but idk how to do it properly, or is it even possible, or shoud I change whole system for better one, since Im still new to socketio?

  • @Je3f0o
    @Je3f0o 2 роки тому

    Eminem?

  • @DoctorMandible
    @DoctorMandible Рік тому

    What's the advantage of using express when you're also using socket?

  • @jonahg6564
    @jonahg6564 3 роки тому +1

    Amazing! Keep the content flowing!

  • @prathameshpatil5860
    @prathameshpatil5860 2 роки тому

    This is awesome but I have a question if I wanted to remove a user from channel(room) how can I do it??

  • @yasteelgungapursat8159
    @yasteelgungapursat8159 2 роки тому

    Explanations are on point👌🏻 but damn I thought the video was sped up🤣

  • @rezaulmasum205
    @rezaulmasum205 3 роки тому

    hey If I would like to access socket in another page like I have multiple controller, how can we pass it to different pages?

  • @ashishafk
    @ashishafk 3 роки тому

    can you please slow down a little its quite fast for me tbh. otherwise video is very helpful.

  • @blameItleaveit
    @blameItleaveit Рік тому

    bro is rapping

  • @saadbaig3060
    @saadbaig3060 2 роки тому

    Very Well Explained!
    You got a new subscriber,
    Thanks.

  • @maheshmahadar4780
    @maheshmahadar4780 3 роки тому

    in my website i cant use @t on multiple pages.
    is it valid or not i am doing ?

  • @josephmenasandoval3419
    @josephmenasandoval3419 3 роки тому

    why you dont use rooms of socket io ? socket io has a buided function

  • @henryho952
    @henryho952 3 роки тому

    Great Content! Thanks! Subscribed! :)

  • @nickvelos9571
    @nickvelos9571 3 роки тому

    Bruf he has surpassed Eminems level of speed speaking

  • @geraldomaga
    @geraldomaga 3 роки тому

    Are u sure that you belong to this planet earth?

  • @GHOST-fe3cu
    @GHOST-fe3cu 2 роки тому

    you make my adhd very happy

  • @mod7ex_fx
    @mod7ex_fx 2 роки тому

    shalom

  • @Lordaniel-K
    @Lordaniel-K 2 роки тому

    מדהים

  • @aleksandrmatyka3118
    @aleksandrmatyka3118 2 роки тому

    It's the best explanation that I've seen

  • @ouss
    @ouss 3 роки тому

    Can you do one with the twilio video rooms API, its easier

    • @CodingWithChaim
      @CodingWithChaim  3 роки тому

      Can certainly take a peek into it

    • @ouss
      @ouss 3 роки тому

      @@CodingWithChaim It would be great and quick in just 10min

  • @brunobuss7005
    @brunobuss7005 3 роки тому

    this guy speaks so fast, i love it

  • @hermitanotherant2930
    @hermitanotherant2930 3 роки тому

    Just adding a callback to the original socket message is genius. Far more elegant than having to respond with a whole new message. Thanks!

  • @jackmiddleton2080
    @jackmiddleton2080 2 роки тому

    1337... My man.

    • @CodingWithChaim
      @CodingWithChaim  2 роки тому

      You’re the first person to comment on this easter egg

  • @milada424
    @milada424 3 роки тому

    9:16 dude's a rap god

  • @realzoogies
    @realzoogies 2 роки тому

    awesome video 👍

  • @theunknownclone8084
    @theunknownclone8084 3 роки тому

    Great video!!!

  • @ikibkilam8383
    @ikibkilam8383 3 роки тому

    Awesome video. Incredibly lucid.

  • @martinn1071
    @martinn1071 3 роки тому +1

    Great stuff. Thanks!
    You might wanna add a beat in the background...it would also make a great rap improv....
    Just saying....
    Thanks again ! Cheers

  • @andresbr92
    @andresbr92 4 роки тому

    Very nice video. Thank you a lot

  • @hanibal43
    @hanibal43 4 роки тому

    always love your vids! would love to see you make more vids on javascript and react

    • @CodingWithChaim
      @CodingWithChaim  4 роки тому

      Thank you! Do you have a specific topic in mind you’d like me to cover?

    • @hanibal43
      @hanibal43 3 роки тому

      @@CodingWithChaim personally I would love to see a full react application using all the react features but as practical components something you would see in real life.

    • @hanibal43
      @hanibal43 3 роки тому

      Would even be great as a separate course explaining the behind the good of the js side

  • @rezaulmasum205
    @rezaulmasum205 4 роки тому

    Will you make any video on private chat ?

    • @CodingWithChaim
      @CodingWithChaim  4 роки тому

      Would you mind elaborating a little more about what you mean?

    • @rezaulmasum205
      @rezaulmasum205 4 роки тому

      @@CodingWithChaim Like there is a list of user in a chat room, but I would like to chat with an specific user. Private chat

    • @CodingWithChaim
      @CodingWithChaim  4 роки тому

      This video covers that too

  • @zxcyuu6141
    @zxcyuu6141 3 роки тому

    Sir, your server.js on github is empty, i wanna know how callback function works.

  • @evoqqqq
    @evoqqqq 3 роки тому

    Great tutorial! Could you please update the github repo because the code from part 1 & 2 is not included. Best regards, evoq!

  • @lucifer4386
    @lucifer4386 3 роки тому

    im trying to make a clone (on a small scale) of discord and believe me this really helped

  • @HeyNelsonn
    @HeyNelsonn 3 роки тому

    Could you teach us how to deploy these apps on Heroku?

  • @ayikkathilkarthik4312
    @ayikkathilkarthik4312 3 роки тому

    That was an awesome explanation.

  • @ikibkilam8383
    @ikibkilam8383 3 роки тому

    Simply awesome! Quite easily, the best channel on youtube.

  • @muhammadhamzahaneefqureshi5016
    @muhammadhamzahaneefqureshi5016 4 роки тому

    Millions subscribers on the way. Great stuff as usual. 😊

  • @capenburbank9307
    @capenburbank9307 3 роки тому

    new to programming here, but learning fast. This has been the best information so far and exactly what I've looked for! You explain everything in depth and it's really quite helpful, I'll be tuning in much more frequently from now on!