I have this app im redirecting from another app and it works but I don't go in the socket io callback on connection. Any idea why? I tried with server.on but I don't go in. Also tired not redirect but going to the address directly.const express = require("express") const socketio = require("socket.io") const http = require("http") const PORT = process.env.PORT || 4040; const chatRouter = require("./router/chat") const app = express() const server = http.createServer(app) const io = socketio(server) io.on("connection", socket => { console.log("[+] New connection established") socket.on("disonnect" , () => { console.log("[+] User has left") }) }) app.get("/", (req, res) => { res.write("This is the devspacer chat server...") res.end() }) app.use(chatRouter) server.listen(PORT, () =>{ console.log("[+] Server listening on port 4040...") })
Submitted June 14, 2020 at 12:50PM by zvado
No comments:
Post a Comment