Automatically remove a user from a "room"

I’ve created a screen that acts like a “Room” and when the user joins the Room they are added to a users property in the Room collection.

I’ve got it set up that they can “leave the room” by clicking a button which will remove them from the users collection.

I’ve also got it set up that if they close the app while in the room, when they return to the room list, a timer will finish and they will be removed from the room.

But if X user is in the room with them, Y user will remain visible in the room until they return to the room list again and get auto updated that they’ve “left”

I can’t seem to think of a way to automatically remove them from the collection if they close the app while in the room. Anyone have any ideas?

1 Like

I don’t have a watertight answer for you necessarily, but maybe an idea that could get the right gears turning for you.

What you basically seem to be looking for is “activity timeout” or “Keep Alive” functionality. Maybe somewhere else in the forum you can find some insight as to whether or not someone has successfully managed that. If you can figure out activity timeout values and marry that up to your room, you may get there.

Could Pragmaflow’s countdown timer constantly update a “last active” timestamp to track engagement with some value in your database? If so, you may be able to set some additional logic that says “if last active time/date is more than X number of seconds before current time then set “Active=False””

Hopefully this gets you swimming in the right direction. Good luck!

Yeah it’s a tough one, I could possibly add a property that logs the current time and a property which updates with a timestamp whenever a certain action is completed and then clears itself.

Then I could check if the timestamp is X amount of time apart from the current time. If it is then it kicks the user out of the room.

Not sure if my thoughts are sound, I’m just at the barbershop on my phone, leaving this thought to try later on and build off lol

This is more of an “if user is afk for set amount of time, then kick them” not exactly what I’m after but I could build off it.

Thanks for steering me in a direction!

1 Like

I figured it out using your tips. Using Pragma Countdown I was able to constantly check if a current time property had been updated within the last X amount of time, if it hadn’t it would triggered a true/false stating the user is afk or inactive and then take them to a “you’ve been kicked out of the room screen” which essentially removes them from the group whether they have the app open or not.

Thanks for getting the thought train rolling!

1 Like

Awesome man! Happy to help and I’m glad you got it figured out.

Sadly they aren’t removed when they don’t have the app open, but I just don’t think this is possible at all. Oh well at least I got a cool AFK kicking feature!

You’re right, “If user is afk for x time, kick them”

Since you already have the pragmaflow timer action in place that logs the user in the room based on timestamps/values, add a new regular countdown timer to the “room” and set it to 3 seconds. Make a list from the button. Set it to Users > current room users. Exclude logged in user via filter: email is not equal to logged in user email.

Use the timestamps you’re using to set “if timestamp is before X minutes” and then add an action to the countdown to remove the current user from the room.

You can set the countdown timer to invisible by setting the border and text colors to transparent. And make the list Sometimes visible if Current Room > users> count is equal to 0 and add the same filter that you’ve added to the list where “if timestamp is before x minutes”.

Will this kick them even if they have the app closed? Because I’m already removing them from the room but it only happens if they have the app open. The timer only seems to countdown if the user is logged in and they have the instance of the timer “active” via their screen

Yes, it will kick them as long as the logged-in user is in the room.

This works because it’s the logged-in user viewing the screen, not the room visitor.

Note, this will not kick a user from the room if no one is in the room.

So if the logged in user leaves the room and then the room visitor leaves, the visitor would remain in there until your other auto update hits or the logged-in user visits the room or a 3rd visitor visits the room.

Now 1 question, can this room have more than 1 visitor? If so, you need to add another parameter to prevent the room creator from being removed from the room when that countdown timer runs.

Assuming you have a “Room Creator” one to many relationship with the user that creates the room and then a many-to-many relationship for users and “Room visitors”.

You can add a filter to also exclude the room creator “where email is not equal to > room creator > email” so that if a 2nd or 3rd user is in the room, it still kicks the inactive users but leaves the room creator.

Nah the room always exists and it’s not owned by anyone, the users just come and go as they please.

Thanks for all of your tips, I’ll have a tinker when the custom formula works again lol

Then you don’t need that extra filter I mentioned and it will work as I had mentioned prior to my last reply.

& Agreed. I feel so helpless without the custom formulas. Since it’s been broken all day, I haven’t been able to work on anything at all.

So just helping out everyone here in the forum today I guess.

Yeah the way I’ve got it set up is basically like a poker room. The tables always exist and there’s set “places” on the screen where the user can join, Then the places around the table are based on which ID they have been given when they join. So there’s only 2 collections - Users and Rooms.

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.