[Freeswitch-users] Socket inbound or outbound with PHP?

Dennis odermann at googlemail.com
Thu Oct 23 08:02:04 PDT 2008


2008/10/23 Anthony Minessale <anthony.minessale at gmail.com>:

Please do not lose patience with me. I am absolutely new to the whole
sip-/phone-/call-thing...

> What messages do you want to send? Be Specific.

For example I want to send the message "playfile" from one process to
another (the call_direction outbound should send this message to the
call_direction inbound).


> Like i said you CANNOT blindly  call sendmsg on any channel that was not
> first parked to indicate you should be controlling it.

This is a point I do not understand. If two persons are talking to
each other, #1 (call_direction inbound) called #2 (call_direction
outbound), and #2 presses a key to play a file for #1, I see no way to
do so, because session #2 can not talk to session #1 (at least not
send a playfile message), when I use event socket outbound.
When both persons are connected to each other, how can I park #1 to
send a message to #1 from #2?


> Probably if you explain *exactly* what you want to accomplish there is some
> simple way to do it.

Ok, then I will try to be a little more precise:

1.) I would like to use event socket outbound, because I have a good
PHP script, which works well and automatically forks a new PHP process
for each call/leg. If one of theses processes dies because of some
problems, all other calls are not affected. I have some problems to
thing the other way round and switch to event socket inbound.
Therefore I would prefer to keep the current PHP script.

2.) I have NO dialplan or something like this! I want to tell fs what
to over my PHP scripts.

3.) I want fs to come and tell my PHP script, if there are new events.
After that, my PHP script tells fs what to do. Then fs tells me, that
it has done what it should, I tell, what to do next.

Here is a detailed example:

1.) fs is connected to my PHP socket-script (not the other way round).

2.) The PHP socket-script registers to "myevents" and "event SESSION_HEARTBEAT".

3.) fs comes with an event and tells, that someone is calling/ringing.
The PHP socket-script forks a new PHP process (p #1), which handles this call.
Then I tell fs to answer (sendmsg answer) and to play a soundfile for
the caller (call_direction inbound).

sendmsg
call-command: execute
execute-app-name: playback
execute-app-arg: /var/www/freeswitch/hello.wav

4.) The caller knows, that if he presses the 1 digit, he will be
connected to a target.

5.) fs tells me, that the call_direction inbound pressed the 1
(event_name:DTMF, dtmf_digit:1).

6.) I tell fs to originate to a target. I do not want to bridge! I
want to control everything for different reasons.

api originate {origination_caller_id_number=1234567,inbound_uuid=".$event['Unique-ID']."}sofia/internal/1001 at 192.168.1.5
123

I pass the uuid of the call_direction inbound/caller to the
call_direction outbound/target, so that the call_direction outbound
knows the uuid of the call_direction inbound (to hopefully send
messages to the process of the call_direction inbound).


7.) The target ansers the call, but the call_direction inbound and the
call_direction outbound are not connected (which is good)
The PHP socket-scripts forks a new PHP process (p #2), which handles
the call_direction outbound/target.

Now I have two calls and two PHP processes.

Now the problems are coming up....

I want thecall_direction outbound to be able to press a digit and to
start a playback for the call_direction inbound/caller.
Because I passed the uuid of the call_direction inbound to the
call_direction outbound, the call_direction outbound knows the uuid
and could use this uuid to send a message to it.

But I can not use sendmsg uuid to do that.
I would like to send from p #2 (call_direction outbound)...

sendmsg 1dca106c-a10c-11dd-b986-d5cdf6924ae6 (which is the uuid of the
call_direction inbound in p #1)
call-command: execute
execute-app-name: playback
execute-app-arg: /var/www/freeswitch/again_hello.wav

... so that the call_direction inbound (in p #1) can hear the again_hello.wav.

Instead, the uuid is ignored and the file is playback for the
call_direction outbound (in p #2). The call with the uuid
1dca106c-a10c-11dd-b986-d5cdf6924ae6 will not hear anything.


I hope this example was a little bit better to understand than my
other examples.



> I'll tell you what, i'll lift that restriction in latest trunk and you tell
> me if it breaks anything or if it makes your life
> easier since it's not really doing much but protecting you from yourself. So
> with latest code you can use your one socket
> to send messages to the other leg too.

That sounds interesting, at least to find out, where my problems are.
I just donwloaded the latest trunk, but the szenario described above
stays the same.

If I send...

sendmsg 1dca106c-a10c-11dd-b986-d5cdf6924ae6 (which is the uuid of the
caller/inbound in p #1)
call-command: execute
execute-app-name: playback
execute-app-arg: /var/www/freeswitch/again_hello.wav

...the file will still be played back for the target/outbound.


Thanks again for your patience
Dennis




More information about the FreeSWITCH-users mailing list