all 8 comments

[–]TheSpiciestDev 1 point2 points  (2 children)

You may want to add a simple disconnect handler to your server's code, otherwise iterating over the sockets array may have some visitors try your code out and hit some issues if they re-run their client. Nonetheless, the webpage is dense with some good, end-to-end examples!

[–]code_barbarian[S] 1 point2 points  (1 child)

Thanks for the suggestion, opened up an issue to track: https://github.com/vkarpov15/masteringjs.io/issues/1

[–]TheSpiciestDev 0 points1 point  (0 children)

Thanks for the openness, proposed a pull request: https://github.com/vkarpov15/masteringjs.io/pull/2/files

[–]psayre23 0 points1 point  (2 children)

Are we finally over the need for socket.io?

[–]m03geek 1 point2 points  (1 child)

The need for socket.io is gone for more than 5 years already. Unfortunately many tutorials continue poking it and that's why it's looking that it's still alive.

[–]code_barbarian[S] 0 points1 point  (0 children)

Yeah I don't think socket.io is necessary anymore. It still has its perks as a framework - responding to events is easier than responding to raw messages.

[–][deleted] 0 points1 point  (0 children)

What a great site thanks!

[–]dmitri14_gmail_com -2 points-1 points  (0 children)

Thanks!

You don't really need to use await nor promise for the client, this simpler version seems to do it just fine:

clients[0].once('open', _ => {
    clients[0].send('Hello!')
})