question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

I'm still getting messages even after leave the room.

See original GitHub issue

Hi all

I’m still getting messages even after leave the room.

Here is the server code.

io.sockets.on( 'connection', function( socket ) {
  console.log('received connection signal');

  //join chat room
  socket.on('join', function(user, room) {
      socket.join(room);
      socket.user = user;
      socket.room = room;
      console.log(user + " Joined the room: "+ room);

  });

  //leave the chat room
  socket.on('leave', function(user, room) {
      socket.room = '';
      console.log(user + " left the room: "+ room);
      socket.broadcast.to(room).emit('disconnected', user, room, 'disconnected');
      socket.leave(room);

  });
});

server.listen(port, function() {
  console.log('Express server listening on %d', port)
});

Can you point me the issue?

Thanks.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:11 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
darrachequesnecommented, Sep 22, 2016

You should use the callback argument of leave:

socket.leave(room, function(){
  socket.broadcast...
});
1reaction
darrachequesnecommented, Oct 26, 2016

@EddieOne could you please provide a sample project reproducing the issue please?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why do I not get my texts until I walk th… - Apple Community
I text my husband at work, but he doesn't get any of them until he walks through the door at home. Then his...
Read more >
Fix problems sending, receiving or connecting to Messages
If you can't send or receive messages, or have trouble connecting to Messages on web, try the following suggestions below. Fix problems sending...
Read more >
What Happens to Texts When Do Not Disturb Is On
Yes, you will continue receiving texts. Do Not Disturb mode on iOS and Android prevents notifications from making noise or appearing on screen....
Read more >
Did You Receive a Text Message From Yourself? You're Not ...
“Spam texts are just increasing at a much more drastic rate than spam calls.” Here's what to look out for with text scams...
Read more >
Socket.io user still receiving messages after disconnection
I was sending an event to leave and rejoin the same room because I set the variable pastRoom equal the the same as...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found