Which socket.io setup is the best/most correct, most up to date?

Tell us what’s happening:
Hi all

I have just started the ‘secure real time multiplayer game’ project. This project requires the use of the ‘socket.io’ library (it is specified in one of the user stories).

I know practically nothing about socket.io (I did do this one challenge on it a while back, https://www.freecodecamp.org/learn/quality-assurance/advanced-node-and-express/authentication-with-socket-io, but did not learn/understand much). I did do some socket stuff using python in the ‘port scanner’ project, but that was python, not javascript.

I’ve looked at some videos online on what socket.io is/what socket.io is for but have noticed that everyone sets up the server side socket and client side socket differently. For example, this guy does it one way:

This other guy does it another way: Learn Socket.io In 30 Minutes - YouTube

The socket.io website does it yet another way: Get started | Socket.IO

etc

I wanted to copy the second guy as his way looks simple, but the boiler plate code provided to us already comes with some lines of code which limit how we can set up the socket.

I was wondering where others who have done this project learned to set up their client side and server side sockets so that I can learn to.

Thanks for your time

Jaime

Your code so far

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36

Challenge: Secure Real Time Multiplayer Game

Link to the challenge:

when i did this project, i went throught the lessons regarding advanced node and express and the sockets ones in particular several times. I dont think the socket you use on python and the one for express are two identical things, altho similar of matter they handle. I also looked up complete projects of other users to see how they handled it. Iirc i did closely watch the vido you link about learning socket in 30min, which was great help to understand how it works.

this is my project https://replit.com/@Sylvant1/boilerplate-project-secure-real-time-multiplayer-game#public/game.mjs

its not fancy, its not polished and there can be misgivings, but it passes the challenge and meets the criteria :wink:

1 Like