Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6251793
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T13:40:48+00:00 2026-05-24T13:40:48+00:00

I am adding a Node JS Chat to my website. At the moment I

  • 0

I am adding a Node JS Chat to my website. At the moment I am clearing the user from the chat if they close the window using the following JQuery method:

$(window).unload(function () {
  jQuery.get("/leave", {id: session.id});
});

This works perfectly and tells the node JS server that the user has closed the window, however this also removes the user from the chat room if they navigate to another page on the website. Is there a way I can tell if they go to another page on the domain and not remove them from the chat? At the moment when they navigate to another page it is being treated as if they are closing the window.

Cheers

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T13:40:48+00:00Added an answer on May 24, 2026 at 1:40 pm

    Check when the user leaves the chat on the server, not the client.

    The only problem I can see with this is that unless you make your pages load with JavaScript you’ll have your users leaving and re-entering the chat every time they navigate the website.

    You can work around this by setting a timeout on the disconnect part. It’s not a perfect solution but it’ll work for most cases.

    if you’re using socket.io here’s some server code:

    socket.on('connection', function (client) {
    
      client.on('disconnect', function () {
        client.broadcast({ action: "quit", clientId: client.sessionId });
      });
    
    });
    

    And in your client-side you can check for action === "quit" and take the appropriate action.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I tried adding a custom method to the Node class but ended up creating
I can copy a node from one XML file to another using org.w3c.dom.Document. importNode(Node
I am looking for a recipe for adding Drupal node records. I have identified
Adding functionality to a class can be done by adding a method or by
Here's my situation: using PHP and MySQL as my backend, jQuery and jsTree for
I'm adding new content to a node, but I'm stuck on what to put
I have an existing complex website built using ASP.NET MVC, including a database backend,
My question is about adding new node to the selected node. For example I
When i am adding node in treeview after selecting any node some time its
I'm simply trying to merge 2 xml documents (adding nodes from one into the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.