I watched some videos and I made a chat app with a socket.io server . Here is my server code :
const app = require("express")();
const server = require("http").createServer(app);
const io = require("socket.io")(server, {
cors: {
origin: "*",
},
});
io.on("connection", (socket) => {
socket.on("chat", (payload) => {
console.log("What is payload", payload);
socket.broadcast.emit("chat", payload);
});
});
// app.listen(5000, () => console.log("server is active..."));
server.listen(5000, () => {
console.log("Server is listening at port 5000...");
});
Now, my question is if this is possible without a server. I just want to show some dummy text with socket.io . My server is on the port 5000 and my localhost on 8080 . Is it possible to make an offline version with a setTimeout to get the dummy text?