From 08339b2038bbb187e5f245555982f16bf0f25838 Mon Sep 17 00:00:00 2001 From: Brian West Date: Tue, 9 Mar 2010 04:12:48 +0000 Subject: [PATCH] allow custom subs to subclass/custom events git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@16952 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- libs/esl/perl/ESL/Dispatch.pm | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/libs/esl/perl/ESL/Dispatch.pm b/libs/esl/perl/ESL/Dispatch.pm index d25ca8f674..1d21934046 100644 --- a/libs/esl/perl/ESL/Dispatch.pm +++ b/libs/esl/perl/ESL/Dispatch.pm @@ -24,7 +24,7 @@ sub init($;$) { $self->{pass} = $args->{pass} ||= "ClueCon"; $self->{_esl} = new ESL::ESLconnection("$self->{host}", "$self->{port}", "$self->{pass}"); $self->{_callback} = undef; - + $self->{_custom_subclass} = undef; return bless($self, $class); } @@ -38,6 +38,10 @@ sub set_callback($;$$) { my $self = shift; my $event = shift; $self->{_callback}->{$event} = shift; + my $subclass = shift; + if($subclass) { + $self->{_custom_subclass} = split(/,/, $subclass); + } } sub render_event($;$) { @@ -75,6 +79,12 @@ sub run($;) { for(;;) { # Only register for events we have callbacks for. for my $key ( keys %{$self->{_callback}} ) { + if ($key eq "CUSTOM") { + foreach $subclass (@{$self->{_custom_subclass}}) { + $self->{_esl}->events("plain", "$key $subclass"); + } + next; + } $self->{_esl}->events("plain", "$key"); }