- Images from Canva and Unsplash!
- monster gif from here
-
ok so how it works is first the client ping the server
-
the server adds the client to the room
-
the client then can send msgs to the room thats it
-
so the client can only do emit events
-
and they can listen on other events
-
the stuff they listen can have like extra parameters depending on the event so thats how data is passed
-
for my example server side
- use
node index.jsto start the example
- use
-
for my example client side
- use the get id to see the id
- then click joinRoom1 to join room1
- then click sendRoom1 to broadcast msg to room one
-
follow this tut to create new node project
-
follow this to get started with sockets in node.js