Hello, I’d like to make something where it senses how many people are on a page and if there are none, it clears all fields in the page’s dataset.
If you click on the ‘enter’ button, it redirects you to a page with an empty dataset and no users. If there are no free pages, a message can appear on your screen. How can I do that?
@russian-dima , In regard to your first sentence, in the PrivateMemebersData collection there’s lastLogin field that gets automatically updated with the specific login time, so no need to create a special collection for that.
(but I must say I did not understand Stef’s question, so maybe it is not relevant).
Hmm, good catch!
So still the question how to be sure who is still online or not?
Running an INTEVAL → checking for UPDATES in this field (for example all 30 secs?
But still i would not know if maybe, the person already leaved, right?
I would still generate a separate DB for it. Why?
For example generating a TRACKING-FUNCTION, which would record the users activity on my site. If no activity for more then (certain amount of time → 5min → no page-change) → LOG-OUT
Instead of poking with intervals, maybe it’ll be better to use wix-realtime.
This way you can publish a message from backend end to front end:
In the masterPage.js create a channel based on current page path/name.
And whenever you want, publish to these channels.
Once the message received on the front-end, it will call a jsw function and report the page name to the backend.
If no message received in the backend - it means no one is connected to this channel. https://www.wix.com/velo/reference/wix-realtime https://www.wix.com/velo/reference/wix-realtime-backend