Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo

FOP2 Community Forum

  1. Home
  2. Support
  3. Send events to connected users from FOP2Callbacks.pm

Send events to connected users from FOP2Callbacks.pm

Scheduled Pinned Locked Moved Support
5 Posts 2 Posters 320 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T
    T
    toxa
    wrote on last edited by
    #1

    Hello.

    I'm trying to make FOP2 chrome app to open URL upon answering any call (not just queue calls) with FOP2Callbacks.pm. I see that FOP2Callbacks.pm is mostly aimed at executing AMI actions, is it possible to send events to connected users from FOP2Callbacks.pm?
    What I'm aiming for is making fop2_server to send notification to client on receiving the BridgeEnter event (like it does on receiving the AgentConnect event).

    1 Reply Last reply
    0
    • N
      N
      nicolas
      wrote on last edited by
      #2

      Hi,

      My suggestion is to use the new plugin architecture to write such a modification. The .pl part of the plugin should contain something similar to this (that might vary depending on your Asterisk version, this sample is for Asterisk 11). You have to use a UserEvent to return a command to the client side (browser/extension), the command you want to send is the notifyconnect (or notifyringing). The event to intercept is "LINK" as fop2 will translate events to make it backwards compatible...

      $AMI_Event_Handler{'bridgepopup'}{'LINK'} = sub {
          my $event = shift;
          my @allreturn;
      
          my $state = ${$event}{'Bridgestate'};
          $canal  = FOP2::utils::get_channel(${$event}{Channel1});
          $canal2 = FOP2::utils::get_channel(${$event}{Channel2});
      
          if($state eq "Link") {
      
              $return  = "Action: UserEvent\r\n";
              $return .= "UserEvent: CustomPopup\r\n";
              $return .= "Channel: $canal\r\n";
              $return .= "Family: notifyconnect\r\n";
              $return .= "Value: $canal2\r\n";
              $return .= "\r\n";
              push @allreturn, $return;
      
          }
      
          return @allreturn;
      };
      

      Look at the sampleplugin source to get an idea of how to use it. You install plugins using the FOP2 Manager.

      http://download.fop2.com/plugins/sampleplugin-1.0.0.tgz

      Best regards,

      1 Reply Last reply
      0
      • T
        T
        toxa
        wrote on last edited by
        #3

        Thanks for your help, I got it to work with FOP2Callbacks.pm (didn't manage to send any events from plugin).
        I have some problems with substitutions in the popup link though. Only #{CLIDNUM} and #{CLIDNAME} work, both #{UNIQUEID} and #{EXTEN} substitute undefined.

        WIP code for Asterisk 13 and FOP2 2.29 (wasn't tested thoroughly):

        #. . .
        sub __prep_chan {
        	my $chan = shift(@_);
        	
        	$chan =~ s/^(.*)-.*/$1/;
        	$chan = uc($chan);
        	
        	return $chan;
        }
        
        sub amiCommand {
        
        	# Received an event from Asterisk Manager Interfase
        
        	$command  = shift;
        
        	if($command eq "DIALEND") {
        		%event = @_;
        		if($event{'DialStatus'} eq 'ANSWER') {
        			my $dst_chan = __prep_chan($event{'DestChannel'});
        			my $src_chan = __prep_chan($event{'Channel'});
        			my $uid = $event{'Uniqueid'};
        			
        			my $return = "";
        			my @allreturn = ();
        			
        			$return = "Action: UserEvent\r\n";
        			$return .= "UserEvent: CustomPopup\r\n";
        			$return .= "Uniqueid: $uid\r\n";
        			$return .= "Channel: $dst_chan\r\n";
        			$return .= "Family: notifyconnect\r\n";
        			$return .= "Value: $src_chan\r\n";
        			$return .= "\r\n";
        			
        			push @allreturn, $return;
        			return @allreturn;
        		}
        	}
        
        #. . .
        }
        
        1 Reply Last reply
        0
        • N
          N
          nicolas
          wrote on last edited by
          #4

          You might need to configure the asterisk manager (manager.conf) to publish the variables you are interested in, something like:

          channelvars=UNIQUEID,SOMETHINGELSE
          
          1 Reply Last reply
          0
          • T
            T
            toxa
            wrote on last edited by
            #5

            Thank you again. Works great now.

            1 Reply Last reply
            0

            Hello! It looks like you're interested in this conversation, but you don't have an account yet.

            Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

            With your input, this post could be even better 💗

            Register Login
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            Powered by NodeBB Contributors
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups