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

123
Visualizações
Angular 10 JWT asp.net core display user online status realtime

Im using angular 10 as my frontend and asp.net core as my backend. I use jwt as my user authentication method. User posts its username and password to the server side and server generates a token sending it back to the user. And I save the token in user's browser local storage. I have written an http interceptor which adds authorization bearer to the header section of user's api requests. This is the way server knows who is who. Now I have a page in which I should display online and offline users with green and red dots next to their names. I can know when a user signs in because it has to login and I can do whateverI want when user signs in but I dont know how to let my client know when users close their browser and leave the site. I am looking for any library, logic or anything to know my user's online/offline status realtime. I should display which users are online and which are not and it should be realtime. I use microsoft identity context to handle membership. Any help is appreciated. Thank you. I need to add that I want a solution rather than code. I just want to know how to do it. I can handle the code work myself. I just want to know how?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Using a web application to know live information about other users sessions will require the server to publish the other user's data in some way.

One approach would be to use a framework to handle server initiate communication via websockets. This would require something like SignalR, for your ASP.NET Core application, for your server to push the user changes. Using websockets is not hard, but it comes with a steep learning curve and more server requirements to attend to.

As Second approach would be to periodically pull the information about the other users (someone called it "hearbeat request" on the question comments). In this approach you create a normal endpoint on your app, and have your front-end page periodically call it to update the user's info. This is much simpler then websockets to implement, and does not add requirements to your current infrastructure.

The difference on the approaches is how close you get to real-time, and the effort to implement it.

  • With websockets the server would push the user session changes as they occur, there cannot be more real-time then this.
  • Without websockets the client would have to keep pulling the user changes, so in the time between pull's you loose some "real-time".
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