Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

240
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda