From 42d9931a4b986c849fe0080c7c79585701ab7a40 Mon Sep 17 00:00:00 2001 From: Petr Baudis Date: Wed, 19 Oct 2011 00:31:18 +0200 Subject: [PATCH] brmd notify_door_*: Route through the main session --- brmd/brmd.pl | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/brmd/brmd.pl b/brmd/brmd.pl index 1e19312..d661ce3 100755 --- a/brmd/brmd.pl +++ b/brmd/brmd.pl @@ -24,7 +24,8 @@ my $alphasign = brmd::Alphasign->new(); POE::Session->create( package_states => [ main => [ qw(_default _start - status_update streaming_update) ], + status_update streaming_update + notify_door_unlocked notify_door_unauth) ], ], heap => { irc => $irc, web => $web, door => $door, stream => $stream, alphasign => $alphasign }, ); @@ -85,6 +86,18 @@ sub streaming_update { $poe_kernel->post( $irc, 'notify_update', 'brmvideo', $st, $streaming ? $streamurl : undef ); } +sub notify_door_unlocked { + my ($self, $nick) = @_[OBJECT, ARG0]; + + $poe_kernel->post($irc, 'notify_door_unlocked', $nick); +} + +sub notify_door_unauth { + my ($self, $cardid) = @_[OBJECT, ARG0]; + + $poe_kernel->post($irc, 'notify_door_unauth'); +} + ## Door serial @@ -179,9 +192,13 @@ sub serial_input { if ($brm =~ s/^CARD //) { print "from door: $input\n"; if ($brm =~ s/^UNKNOWN //) { - $poe_kernel->post($irc, 'notify_door_unauth', $brm); + foreach (@{$self->{observers}}) { + $poe_kernel->post($_, 'notify_door_unauth', $brm); + } } else { - $poe_kernel->post( $irc, 'notify_door_unlocked', $brm ); + foreach (@{$self->{observers}}) { + $poe_kernel->post($_, 'notify_door_unlocked', $brm); + } } } } @@ -628,7 +645,7 @@ sub notify_update { } sub notify_door_unauth { - my ($sender, $cardid) = @_[SENDER, ARG0]; + my ($sender) = $_[SENDER]; my $irc = $_[HEAP]->{irc}; my $msg = "[door] unauthorized access denied!"; $irc->yield (privmsg => $channel => $msg );