Back

Responding using realtime when a user logs in from another device

  • 0
  • Flutter
  • Realtime
  • Accounts
D3str0y3d255
27 Jun, 2023, 13:25

Hello again! I am trying to use appwrites realtime functionality, I want to have it to where if a user logs in on another device it will realtime kick them out of the first device, I am subscribed on session and when i login i get one realtime event, But when logging in from another device with the same credentials it wont boot the first instance.

I've read the docs on realtime quite abit and cant quite figure out what I'm doing incorrectly

My appwrite instance is setup to limit users to 1 Session When they are able to login, I create the realtime subscription within the class i have to handle auth client side. it's listening for a session deleted event in my main function so that i can redirect them as needed without using Providers. I know when they login i get a print of their subscription subscription: /v1/realtime?project=[ProjectID]channels[Channels]=account but when i login from the other device (or logout on my current device (even though im deleting the current session)) i don't get another print that a session was deleted.

TL;DR
The user is facing issues with implementing real-time functionality in their app. They are trying to kick out a user from their first device when they log in from another device. They are using Appwrite's user session limit, but it is not working as expected, as it prevents new sessions rather than removing old sessions. The user is unsure if they should handle this limitation themselves or if there is another way to implement it using real-time functionality. They also mentioned that the WebSocket connection gets disconnected when using real-time with the account. They suggest calling the delete session method after logging in to log out previous devices. However, they are not able to
Drake
27 Jun, 2023, 18:48

Things get weird when trying to use realtime with account because the websocket can get disconnected.

I would suggest calling delete session after logging in to log out previous devices.

D3str0y3d255
27 Jun, 2023, 23:00

Gotcha! Is using appwrites user session limit ill-advised when using realtime to listen to the account, and instead i should be handling that when I sign in the user (by deleting old session)?

Drake
27 Jun, 2023, 23:15

The session limit seems to prevent new sessions rather than removing old sessions

D3str0y3d255
28 Jun, 2023, 22:45

Also just want to say thank you for your assistance so far Steven! You have been awesome and the time you've been willing to give assistance is greatly appreciated! <a:Prayge2:846611105602338836>

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more