package FOP2Callbacks; # Example module to customize and tweak FOP2 behaviour my %redirected; sub flashCommand { # This function is called when certain commands are sent from a flash client $command = shift; @parameters = @_; my $return = ""; my @allreturn = (); if($command eq "setastdb") { # DND Integration from FOP2 to FreePBX ASTDB DND # This is for debug # my $cont=0; # foreach my $param (@parameters) { # $cont++; # print "Parametro $cont = $param\n"; # } if($parameters[3] ne "") { $return = "Action: Command\r\n"; $return .= "Command: database put DND ".$parameters[2]." YES\r\n"; $return .= "\r\n"; push @allreturn, $return; } else { $return = "Action: Command\r\n"; $return .= "Command: database del DND ".$parameters[2]."\r\n"; $return .= "\r\n"; push @allreturn, $return; } return @allreturn; } elsif($command eq "pickupActive") { #my $cont=0; #foreach my $param (@parameters) { # $cont++; # print "comando $comando -- Parametro $cont = $param\n"; #} $redirected{$parameters[0]}=1; #print "seteo redirected de ".$parameters[1]."\n"; return @allreturn; } elsif($command eq "auth") { #print "llego un auth, no devuelvo nada\n"; #foreach my $param (@parameters) { # $cont++; # print "Parametro $cont = $param\n"; #} return @allreturn; } } sub amiCommand { # Received an event from Asterisk Manager Interfase $command = shift; if($command eq "LEAVE") { # Used with fop2-dummy context for writing a line # to queue_log so redirects OUT of a queue are not # counted as abandoned calls %event = @_; my $return = ""; my @allreturn = (); if( defined ( $redirected { $event{Channel} } )) { # Este abandono es en realidad una redireccion delete $redirected { $event{Channel} }; my $tiempo = time(); $tiempo = $tiempo + 30; my $uniid = $event{Uniqueid}; my $queue = $event{Queue}; $return = "Action: Originate\r\n"; $return .= "Channel: Local/dummy\@fop2-dummy/n\r\n"; $return .= "Application: QueueLog\r\n"; $return .= "Data: $queue,$uniid,NONE,NOTABANDON,0,0,0\r\n"; $return .= "Async: true\r\n"; $return .= "\r\n"; push @allreturn, $return; return @allreturn; } } elsif($command eq "HANGUP") { # Garbage Collect %event = @_; if( defined ( $redirected { $event{Channel} } )) { # Este abandono es en realidad una redireccion delete $redirected { $event{Channel} }; } } } 1;