Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

234
Views
Signalr JS serverless close session

Coming from socket.io I had on the server side the following code:

  socket.on("disconnect", async () => {})

When the user closes the Tap or refreshes the page.

I need to know if I can implement the same functionality, (ofc different implementation) on the server side (in the attached highlighted) or if it is doable do I need to create an HttpTrigger that calls the process needed in the disconnect functionality? enter image description here

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

After digging through the issue I had finally found a solution:

  <script>
window.onbeforeunload = function (e) {
  const data = {
    userId: localStorage.getItem("outside"),
  }
  console.log("looog", data);
  // alert("IUIUIU")
  fetch("API_URL_ENDS_THE_SESSION", {
    method: "POST",
    headers: {
      "Content-Type": "application/json",
    },
    body: JSON.stringify(data),
  })

  e = e || window.event;

  // // For IE and Firefox prior to version 4
  if (e) {
    e.returnValue = 'Sure?';
  }

  // // For Safari
  return 'Sure?';
}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!