My attention is to get logged in ( online user list). how this is possible as appwrite server sdk is not ready for realtime yet.
Logging in does not translate to "online users"
What so you mean? So when I subscribe to account channel! It returns session is not valid
So can we get something like userId of logged in user!
I understand other security related info cannot be received!
Please be as informative as you can. As your original post does not really explain anything. When a user signs in, that user receives a session object. How do you define "online user" in this context?
How does your approach look like? What is your code? You have to provide a lot more information than that
const client = new Client()
.setEndpoint('https://cloud.appwrite.io/v1')
.setProject('<PROJECT_ID>');
client.subscribe('account', response => {
// Callback will be executed on all account events.
console.log(response);
});
``` based on the document, I. could use real time to subcribe to account channel, so whenever user create session ( login) it would return to the subcriber! my intension is to collect those user id having the sessions (login) . then in the system can identified them as online or active.
In appwrite functions you are supposed to use the event trigger https://appwrite.io/docs/advanced/platform/events
Also the user can stop the app in the meantime. So not sure what you mean with "online" and "active"
Just because the user logged in at some point does not nessecarily mean that the user is online as long as the session is active
user should be considered active until it left broswer
And how are you going to know when it leaves?
if I use nextjs, onroot layout component disposed, trigger to remove from the collection. then all subcriber should be notified
the workaround solution for this I could think of is creating separated collection UserActive , and when user login -> manually update add userId to the collection then giving real time subcription to that collection! however, i see there is way to subcribe to 'account' channel, which should be more appropriate
Recommended threads
- Invalid document structure: missing requ...
I just pick up my code that's working a week ago, and now I got this error: ``` code: 400, type: 'document_invalid_structure', response: { message: 'Inv...
- custom domain with CloudFlare
Hi all, it seems that CloudFlare has blocked cross-domain CNAME link which made my app hostname which is in CloudFlare, unable to create a CNAME pointing to clo...
- Custom emails
What happen if I use a third party email provider to customize my emails and my plan run out of emails/month? Appwrite emails are used as fallback sending emai...