Subject: | GoSub feature |
Asterisk::AGI does not appear to have implemented the GOSUB feature. As per ASTERISK-12114, $agi->exec(gosub) is not proper; we are to use a native $agi->gosub(..).
The attached patch implements a local gosub() which seems to work with Asterisk 11.5, however, a console notice regarding "Abnormal AGI exit" is printed. Looking into that.
Subject: | agi.pm.diff |
--- AGI.pm.orig 2013-09-11 02:04:40.000000000 -0400
+++ AGI.pm 2013-09-11 02:42:51.000000000 -0400
@@ -568,6 +568,32 @@
return $result;
}
+=item $AGI->gosub($context,$extension,$priority,$arg);
+
+Executes AGI Command "GOSUB @args"
+
+Jump to a particular context, extension, and priority, saving the return address.
+
+Example: $AGI->gosub('extensions','s',1,'MyArgument');
+
+Returns: 0, or -1 if the given context, extension, or priority is invalid.
+
+=cut
+
+sub gosub {
+ my ($self, $context, $extension, $priority, $arg) = @_;
+
+ my $result = undef;
+
+ if ($self->execute("GOSUB $context $extension $priority $arg")) {
+ my $tempresult = $self->_lastresponse();
+ if ($tempresult =~ /\((.*)\)/) {
+ $result = $1;
+ }
+ }
+ return $result;
+}
+
=item $AGI->hangup($channel)
Executes AGI Command "HANGUP $channel"