mirror of
https://github.com/brmlab/brmdoor.git
synced 2025-06-08 03:34:02 +02:00
brmd notify_door_*: Route through the main session
This commit is contained in:
parent
fa974afcc9
commit
42d9931a4b
1 changed files with 21 additions and 4 deletions
25
brmd/brmd.pl
25
brmd/brmd.pl
|
@ -24,7 +24,8 @@ my $alphasign = brmd::Alphasign->new();
|
||||||
POE::Session->create(
|
POE::Session->create(
|
||||||
package_states => [
|
package_states => [
|
||||||
main => [ qw(_default _start
|
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 },
|
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 );
|
$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
|
## Door serial
|
||||||
|
|
||||||
|
@ -179,9 +192,13 @@ sub serial_input {
|
||||||
if ($brm =~ s/^CARD //) {
|
if ($brm =~ s/^CARD //) {
|
||||||
print "from door: $input\n";
|
print "from door: $input\n";
|
||||||
if ($brm =~ s/^UNKNOWN //) {
|
if ($brm =~ s/^UNKNOWN //) {
|
||||||
$poe_kernel->post($irc, 'notify_door_unauth', $brm);
|
foreach (@{$self->{observers}}) {
|
||||||
|
$poe_kernel->post($_, 'notify_door_unauth', $brm);
|
||||||
|
}
|
||||||
} else {
|
} 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 {
|
sub notify_door_unauth {
|
||||||
my ($sender, $cardid) = @_[SENDER, ARG0];
|
my ($sender) = $_[SENDER];
|
||||||
my $irc = $_[HEAP]->{irc};
|
my $irc = $_[HEAP]->{irc};
|
||||||
my $msg = "[door] unauthorized access denied!";
|
my $msg = "[door] unauthorized access denied!";
|
||||||
$irc->yield (privmsg => $channel => $msg );
|
$irc->yield (privmsg => $channel => $msg );
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue