From 211800e6dc77a5444601c828bf914bd5cac8b7fa Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Tue, 14 Jul 2015 11:34:32 +0200 Subject: [PATCH] Prevent uninit value being logged --- vroom.pl | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/vroom.pl b/vroom.pl index e8d1f4e..75fce9a 100755 --- a/vroom.pl +++ b/vroom.pl @@ -1335,10 +1335,12 @@ websocket '/socket.io/:ver/websocket/:id' => sub { # Triggerred when a websocket connection ends $self->on(finish => sub { my ($self, $code, $reason) = @_; - $self->log_event({ - event => 'room_leave', - msg => "Peer $id closed websocket connection, leaving room " . $peers->{$id}->{room} - }); + if ($id && $peers->{$id} && $peers->{$id}->{room}){ + $self->log_event({ + event => 'room_leave', + msg => "Peer $id closed websocket connection, leaving room " . $peers->{$id}->{room} + }); + } $self->signal_broadcast_room({ from => $id, msg => Protocol::SocketIO::Message->new(