You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to make a socket-io application where users can join a room and then chat with other users in the same room. And I am using the following code to do so:
var app = require("express")();
var http = require("http").Server(app);
var io = require("socket.io")(http);
const port = 5001;
app.get("/", function (req, res) {
res.sendFile(__dirname + "/index.html");
});
io.on("connection", function (socket) {
console.log("a user connected");
socket.on("join_room", (room) => {
socket.join(room);
socket.emit("message", "Successfully joined the room")
});
socket.on("message", ({ room, message }) => {
io.to(room).emit("message", {
message,
name: "Friend",
});
});
I am using Firecamp as the frontend for this server but whenever I run the program above, the users connected to the room are not shown the message. Screenshots : Emitting the message event and yet not recieving the message in the other tab
A small repo to reproduce the error can be found at https://github.com/divided7/socket-io-frontend-issue Before my question gets removed because "it is not a single question but a collection of many", I would like you to consider that the problem is only with a specific section of the code which I am unable to find. Thanks for the help!
The text was updated successfully, but these errors were encountered:
I am trying to make a socket-io application where users can join a room and then chat with other users in the same room. And I am using the following code to do so:
var app = require("express")();
var http = require("http").Server(app);
var io = require("socket.io")(http);
const port = 5001;
app.get("/", function (req, res) {
res.sendFile(__dirname + "/index.html");
});
io.on("connection", function (socket) {
console.log("a user connected");
socket.on("join_room", (room) => {
socket.join(room);
socket.emit("message", "Successfully joined the room")
});
socket.on("message", ({ room, message }) => {
io.to(room).emit("message", {
message,
name: "Friend",
});
});
I am using Firecamp as the frontend for this server but whenever I run the program above, the users connected to the room are not shown the message. Screenshots : Emitting the message event and yet not recieving the message in the other tab
A small repo to reproduce the error can be found at https://github.com/divided7/socket-io-frontend-issue Before my question gets removed because "it is not a single question but a collection of many", I would like you to consider that the problem is only with a specific section of the code which I am unable to find. Thanks for the help!
The text was updated successfully, but these errors were encountered: