mirror of
https://github.com/dani/vroom.git
synced 2024-06-29 15:03:41 +02:00
Purge expired rooms and invitation in an IOLoop instead of the ping hack
This commit is contained in:
parent
dcfffb6b58
commit
c6a39b7c0c
11
vroom.pl
11
vroom.pl
|
@ -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
|
# Route / to the index page
|
||||||
get '/' => sub {
|
get '/' => sub {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
|
@ -1566,11 +1572,6 @@ any '/api' => sub {
|
||||||
# Handle activity pings sent every minute by each participant
|
# Handle activity pings sent every minute by each participant
|
||||||
elsif ($req->{action} eq 'ping'){
|
elsif ($req->{action} eq 'ping'){
|
||||||
$self->update_room_last_activity($room->{name});
|
$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
|
# Check if we got any invitation response to process
|
||||||
my $invitations = $self->get_invitation_list($self->session('id'));
|
my $invitations = $self->get_invitation_list($self->session('id'));
|
||||||
my $msg = '';
|
my $msg = '';
|
||||||
|
|
Loading…
Reference in New Issue
Block a user