Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Socket.IO client side not listening even after emitting an event #3584

Closed
diivi opened this issue Apr 25, 2020 · 0 comments
Closed

Socket.IO client side not listening even after emitting an event #3584

diivi opened this issue Apr 25, 2020 · 0 comments

Comments

@diivi
Copy link

diivi commented Apr 25, 2020

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant