Update activity timestamp for each peer when they ping a room

master
Daniel Berteaud 11 years ago
parent c97c1f6866
commit fdb2840451
  1. 9
      public/vroom.pl

@ -397,9 +397,12 @@ helper delete_room => sub {
helper ping_room => sub { helper ping_room => sub {
my $self = shift; my $self = shift;
my ($name) = @_; my ($name) = @_;
return undef unless ( %{ $self->get_room($name) }); my $data = $self->get_room($name);
my $sth = eval { $self->db->prepare("UPDATE `rooms` SET `activity_timestamp`=? WHERE `name`=?;") } || return undef; return undef unless ($data);
$sth->execute(time(),$name) || return undef; my $sth = eval { $self->db->prepare("UPDATE `rooms` SET `activity_timestamp`=? WHERE `id`=?;") } || return undef;
$sth->execute(time(),$data->{id}) || return undef;
$sth = eval { $self->db->prepare("UPDATE `participants` SET `activity_timestamp`=? WHERE `id`=? AND `participant`=?;") } || return undef;
$sth->execute(time(),$data->{id},$self->session('name')) || return undef;
$self->app->log->debug($self->session('name') . " pinged the room $name"); $self->app->log->debug($self->session('name') . " pinged the room $name");
return 1; return 1;
}; };

Loading…
Cancel
Save