So if we implement socket into node server, and add a code (event handler) to follow a connection, it will show the first connection but not the others.
I understand it is working normally if we implement in the html a socket client side but i don’t understand why it is just showing just first connection that has been cought if we dont implement a socket client side.
const express = require("express")
const { readFileSync } = require("fs")
let http = require("http")
const {Server} = require("socket.io")
let app = express()
let server = http.createServer(app)
let socket = new Server(server)
app.get("/", (request, response)=> {
response.send(`<center>
<h1>CEKANJE NA DOVOLJAN BROJ KORISNIKA
</h1>
</center>`)
})
socket.on("connection", (korisnik)=>{
console.log(korisnik.id)
})
server.listen(5000, ()=> {
console.log("server pokrenut")
})