1
0
mirror of https://github.com/dani/vroom.git synced 2024-06-18 12:19:13 +02:00

Purge expired rooms and invitation in an IOLoop instead of the ping hack

This commit is contained in:
Daniel Berteaud 2015-06-17 09:23:27 +02:00
parent dcfffb6b58
commit c6a39b7c0c

View File

@ -1186,6 +1186,12 @@ Mojo::IOLoop->recurring( 3 => sub {
}
});
# Purge every 5 minutes
Mojo::IOLoop->recurring( 300 => sub {
app->purge_rooms;
app->purge_invitations;
});
# Route / to the index page
get '/' => sub {
my $self = shift;
@ -1566,11 +1572,6 @@ any '/api' => sub {
# Handle activity pings sent every minute by each participant
elsif ($req->{action} eq 'ping'){
$self->update_room_last_activity($room->{name});
# Cleanup expired rooms every ~10 pings
if ((int (rand 100)) <= 10){
$self->purge_rooms;
$self->purge_invitations;
}
# Check if we got any invitation response to process
my $invitations = $self->get_invitation_list($self->session('id'));
my $msg = '';