[Freeswitch-users] Event Socket Questions - Followup

freeswitch-users at lists.freeswitch.org freeswitch-users at lists.freeswitch.org
Tue Jan 8 00:14:01 PST 2008


Ok, thanks to support here, on IRC and from Anthony, I have gotten this
working about 80%.  None of my current issues are due to FreeSwitch, so
I thought I'd post what I have completed so far and what I had learned
along the way.

Here is a link to the PHP abstraction layer that we're working on:
http://phoneflyers.com/phpEvents.zip

It's basically similar to the Client.pm Perl client but in PHP.  (I can
defend the reason to do this in PHP another time -- it's the right
choice for us right now.)

It is horribly ugly at the moment, but the Event Socket is working as
advertised.  I get the appropriate events (DTMF is what I've been caring
about), and I can invoke raw commands and sendMsg style call control
messages.  The base server class forks a child for each connection, and
has enough of a framework to notify your subclass when some of the
interesting events happen.  There is a readme.txt in the zip file with a
little more info.

To summarize what I've learned along the way (thanks to Anthony, Vile,
etc) is the following:

1) In outbound mode, you need to setup your calls to take 'async' and
not 'full' in your dialplan like so. (Pretty much any other combination
does not work as you want in this case.)
   <extension name="socketTest">
      <condition field="destination_number" expression="^444$">
        <action application="socket" data="127.0.0.1:9090 async"/>
      </condition>
    </extension>

2) To setup your events in outbound mode, use the raw command 'myevents'
with no parameters.  I haven't found this documented, but if you also
add an 'events plain ALL' or the like, you will get events from all
calls, not just yours.

3) sendMsg() calls are used to make requests on the current call without
needing a UUID.  I am just deriving this from what I've seen -- feel
free to correct me.  API (and bgapi) calls are much more useful in
inbound (full) mode.

4) Socket timeouts in PHP do not work as expected when reading until
newlines.  This is just a gripe since I haven't figured this out yet
;-)  Any help would be appreciated since I can't do DTMF timouts until I
figure it out.

This is by no means done, but I've gotten several emails that people are
working on similar efforts, so I thought I'd share.  Next up, I want to
get some higher level calls (similar to the Session calls in Javascript)
that run on top of this low-level interface.

Thanks for everyone's help,
Bill

Bill Binko wrote:
> Ok, I have gotten the DTMF to work, and am much happier now.  I have a 
> nice framework forming that will make it easy for us to develop 
> PHP-based IVR apps, monitors, etc.
>
> Live is looking better.
>
> However, I have some questions about the Event Socket interface that I 
> would love some help on.
>
> First, it seems that when in 'async full' mode, you get ALL the events 
> for any connections, not just the one you were invoked on (in outbound 
> mode).  If that's true, how do I discern which events are for my call?  
> I suppose I could use the UUID in the Event, but that seems fairly 
> wasteful - shouldn't I be able to just register for "my" events (that's 
> why I'm calling "myevents" ;-)
>
> Second, what is the difference between the three ways to invoke 
> functionality?  There's the "basic" commands like "myevents", "event 
> plain ALL", "log DEBUG".  Then there are the api commands that are 
> invoked like "api uuid_broadcast <UUID> <path>", and then there are the 
> sendMsg command like "sendmsg\ncall-command: execute\nexecute-app-name: 
> answer\nexecute-app-arg: \n\n"
>
> Each of these seem to invoke functionality in the current call (or the 
> call with the given UUID), and there seems to be overlap (i.e. there is 
> an 'answer' command in the API), but they all have different syntaxes, 
> Content-Types and corresponding result messages.
>
> This isn't a complaint, I'm just trying to sort out when to use each.  
> I'll be happy to update the wiki with the clarification.
>
> Finally, assuming this becomes reasonably usable, how do I add it to the 
> contributed scripts?
>
> Thanks,
> Bill
>
>
> _______________________________________________
> Freeswitch-users mailing list
> Freeswitch-users at lists.freeswitch.org
> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
> http://www.freeswitch.org
>
>   






More information about the FreeSWITCH-users mailing list