Would someone please take a look at this simple PHP event socket script and tell me what I am doing wrong - or tell me that this could be a bug elsewhere? Any help would be appreciated. When I run the script without the call to execute(), everything seems fine. When I include the call to execute(), the calls to getType() return CUSTOM for a while, then later start to return the correct name. #!/usr/bin/php <?php require_once 'ESL.php'; $endPoint = 'sofia/internal/695%192.168.100.132'; $eventSocket = New ESLconnection('192.168.100.132', '8021', 'ClueCon'); $event = $eventSocket->events('plain', 'ALL'); // call endpoint, get uuid $event = $eventSocket->api('originate', $endPoint . ' &park'); $serializedEvent = explode("\n", $event->serialize()); foreach ($serializedEvent as $eventLine) { list($dummy, $uuid) = explode('+OK ', $eventLine); if ($uuid) { break; } } // play announcement to endpoint $event = $eventSocket->execute('playback', '/opt/ann/user-busy.wav', $uuid); // monitor events while (TRUE) { echo "getType: " . $event->getType() . "\n"; $serializedEvent = explode("\n", $event->serialize()); foreach ($serializedEvent as $eventLine) { list($header, $value) = explode(': ', $eventLine); if ($header == "Event-Name") { printf($eventLine . "\n"); } if ($header == "Content-Type") { printf($eventLine . "\n"); } } printf("\n"); $event = $eventSocket->recvEvent(); }?> Run without the call to execute(): ================================== getType: CUSTOM Content-Type: api/response getType: CHANNEL_CREATE Event-Name: CHANNEL_CREATE getType: CHANNEL_OUTGOING Event-Name: CHANNEL_OUTGOING getType: CHANNEL_ORIGINATE Event-Name: CHANNEL_ORIGINATE getType: CHANNEL_STATE Event-Name: CHANNEL_STATE getType: PRESENCE_IN Event-Name: PRESENCE_IN getType: CHANNEL_STATE Event-Name: CHANNEL_STATE getType: PRESENCE_IN Event-Name: PRESENCE_IN getType: CHANNEL_STATE Event-Name: CHANNEL_STATE getType: CALL_UPDATE Event-Name: CALL_UPDATE getType: CHANNEL_PROGRESS Event-Name: CHANNEL_PROGRESS getType: HEARTBEAT Event-Name: HEARTBEAT getType: HEARTBEAT Event-Name: RE_SCHEDULE getType: CALL_UPDATE Event-Name: CALL_UPDATE getType: CODEC Event-Name: CODEC getType: CODEC Event-Name: CODEC getType: CHANNEL_ANSWER Event-Name: CHANNEL_ANSWER getType: PRESENCE_IN Event-Name: PRESENCE_IN getType: API Event-Name: API getType: PRESENCE_IN Event-Name: PRESENCE_IN getType: CHANNEL_STATE Event-Name: CHANNEL_STATE getType: CHANNEL_EXECUTE Event-Name: CHANNEL_EXECUTE getType: CHANNEL_PARK Event-Name: CHANNEL_PARK getType: CHANNEL_HANGUP Event-Name: CHANNEL_HANGUP getType: CHANNEL_UNPARK Event-Name: CHANNEL_UNPARK getType: CHANNEL_EXECUTE_COMPLETE Event-Name: CHANNEL_EXECUTE_COMPLETE getType: PRESENCE_IN Event-Name: PRESENCE_IN getType: CHANNEL_STATE Event-Name: CHANNEL_STATE getType: PRESENCE_IN Event-Name: PRESENCE_IN getType: CHANNEL_HANGUP_COMPLETE Event-Name: CHANNEL_HANGUP_COMPLETE getType: CHANNEL_STATE Event-Name: CHANNEL_STATE getType: CHANNEL_DESTROY Event-Name: CHANNEL_DESTROY getType: CHANNEL_STATE Event-Name: CHANNEL_STATE Run with the call to execute(): =============================== getType: CUSTOM Content-Type: command/reply getType: CUSTOM Content-Type: text/event-plain Event-Name: CHANNEL_CREATE getType: CUSTOM Content-Type: text/event-plain Event-Name: CHANNEL_OUTGOING getType: CUSTOM Content-Type: text/event-plain Event-Name: CHANNEL_ORIGINATE getType: CUSTOM Content-Type: text/event-plain Event-Name: CHANNEL_STATE getType: CUSTOM Content-Type: text/event-plain Event-Name: PRESENCE_IN getType: CUSTOM Content-Type: text/event-plain Event-Name: CHANNEL_STATE getType: CUSTOM Content-Type: text/event-plain Event-Name: PRESENCE_IN getType: CUSTOM Content-Type: text/event-plain Event-Name: CHANNEL_STATE getType: CUSTOM Content-Type: text/event-plain Event-Name: CALL_UPDATE getType: CUSTOM Content-Type: text/event-plain Event-Name: CHANNEL_PROGRESS getType: CUSTOM Content-Type: text/event-plain Event-Name: CALL_UPDATE getType: CUSTOM Content-Type: text/event-plain Event-Name: CODEC getType: CUSTOM Content-Type: text/event-plain Event-Name: CODEC getType: CUSTOM Content-Type: text/event-plain Event-Name: CHANNEL_ANSWER getType: CUSTOM Content-Type: text/event-plain Event-Name: PRESENCE_IN getType: CUSTOM Content-Type: text/event-plain Event-Name: API getType: CUSTOM Content-Type: text/event-plain Event-Name: PRESENCE_IN getType: CUSTOM Content-Type: text/event-plain Event-Name: CHANNEL_STATE getType: CUSTOM Content-Type: text/event-plain Event-Name: CHANNEL_EXECUTE getType: CUSTOM Content-Type: text/event-plain Event-Name: CHANNEL_PARK getType: CHANNEL_EXECUTE Event-Name: CHANNEL_EXECUTE getType: CHANNEL_HANGUP Event-Name: CHANNEL_HANGUP getType: CHANNEL_EXECUTE_COMPLETE Event-Name: CHANNEL_EXECUTE_COMPLETE getType: COMMAND Event-Name: COMMAND getType: CHANNEL_UNPARK Event-Name: CHANNEL_UNPARK getType: CHANNEL_EXECUTE_COMPLETE Event-Name: CHANNEL_EXECUTE_COMPLETE getType: PRESENCE_IN Event-Name: PRESENCE_IN getType: CHANNEL_STATE Event-Name: CHANNEL_STATE getType: PRESENCE_IN Event-Name: PRESENCE_IN getType: CHANNEL_HANGUP_COMPLETE Event-Name: CHANNEL_HANGUP_COMPLETE getType: CHANNEL_STATE Event-Name: CHANNEL_STATE getType: CHANNEL_DESTROY Event-Name: CHANNEL_DESTROY getType: CHANNEL_STATE Event-Name: CHANNEL_STATE Thanks, Ron
I do not know if really helps you but we are facing the same problem in one of our implementations using the ESL.so for PHP. We have only see this problem when subscribing to the CHANNEL_STATE getType() should always match EventName... but it does not ./aep -- Stopping junk mailers is good for the environment
Would someone please take a look at this simple PHP event socket script and tell me what I am doing wrong - or tell me that this could be a bug elsewhere? Any help would be appreciated.
When I run the script without the call to execute(), everything seems fine. When I include the call to execute(), the calls to getType() return CUSTOM for a while, then later start to return the correct name.
#!/usr/bin/php <?php require_once 'ESL.php'; $endPoint = 'sofia/internal/695%192.168.100.132';
$eventSocket = New ESLconnection('192.168.100.132', '8021', 'ClueCon'); $event = $eventSocket->events('plain', 'ALL');
// call endpoint, get uuid $event = $eventSocket->api('originate', $endPoint . ' &park'); $serializedEvent = explode("\n", $event->serialize()); foreach ($serializedEvent as $eventLine) { list($dummy, $uuid) = explode('+OK ', $eventLine); if ($uuid) { break; } }
// play announcement to endpoint $event = $eventSocket->execute('playback', '/opt/ann/user-busy.wav', $uuid);
// monitor events while (TRUE) { echo "getType: " . $event->getType() . "\n"; $serializedEvent = explode("\n", $event->serialize()); foreach ($serializedEvent as $eventLine) { list($header, $value) = explode(': ', $eventLine); if ($header == "Event-Name") { printf($eventLine . "\n"); } if ($header == "Content-Type") { printf($eventLine . "\n"); } }
printf("\n"); $event = $eventSocket->recvEvent(); }?>
Run without the call to execute(): ================================== getType: CUSTOM Content-Type: api/response
getType: CHANNEL_CREATE Event-Name: CHANNEL_CREATE
getType: CHANNEL_OUTGOING Event-Name: CHANNEL_OUTGOING
getType: CHANNEL_ORIGINATE Event-Name: CHANNEL_ORIGINATE
getType: CHANNEL_STATE Event-Name: CHANNEL_STATE
getType: PRESENCE_IN Event-Name: PRESENCE_IN
getType: CHANNEL_STATE Event-Name: CHANNEL_STATE
getType: PRESENCE_IN Event-Name: PRESENCE_IN
getType: CHANNEL_STATE Event-Name: CHANNEL_STATE
getType: CALL_UPDATE Event-Name: CALL_UPDATE
getType: CHANNEL_PROGRESS Event-Name: CHANNEL_PROGRESS
getType: HEARTBEAT Event-Name: HEARTBEAT
getType: HEARTBEAT Event-Name: RE_SCHEDULE
getType: CALL_UPDATE Event-Name: CALL_UPDATE
getType: CODEC Event-Name: CODEC
getType: CODEC Event-Name: CODEC
getType: CHANNEL_ANSWER Event-Name: CHANNEL_ANSWER
getType: PRESENCE_IN Event-Name: PRESENCE_IN
getType: API Event-Name: API
getType: PRESENCE_IN Event-Name: PRESENCE_IN
getType: CHANNEL_STATE Event-Name: CHANNEL_STATE
getType: CHANNEL_EXECUTE Event-Name: CHANNEL_EXECUTE
getType: CHANNEL_PARK Event-Name: CHANNEL_PARK
getType: CHANNEL_HANGUP Event-Name: CHANNEL_HANGUP
getType: CHANNEL_UNPARK Event-Name: CHANNEL_UNPARK
getType: CHANNEL_EXECUTE_COMPLETE Event-Name: CHANNEL_EXECUTE_COMPLETE
getType: PRESENCE_IN Event-Name: PRESENCE_IN
getType: CHANNEL_STATE Event-Name: CHANNEL_STATE
getType: PRESENCE_IN Event-Name: PRESENCE_IN
getType: CHANNEL_HANGUP_COMPLETE Event-Name: CHANNEL_HANGUP_COMPLETE
getType: CHANNEL_STATE Event-Name: CHANNEL_STATE
getType: CHANNEL_DESTROY Event-Name: CHANNEL_DESTROY
getType: CHANNEL_STATE Event-Name: CHANNEL_STATE
Run with the call to execute(): =============================== getType: CUSTOM Content-Type: command/reply
getType: CUSTOM Content-Type: text/event-plain Event-Name: CHANNEL_CREATE
getType: CUSTOM Content-Type: text/event-plain Event-Name: CHANNEL_OUTGOING
getType: CUSTOM Content-Type: text/event-plain Event-Name: CHANNEL_ORIGINATE
getType: CUSTOM Content-Type: text/event-plain Event-Name: CHANNEL_STATE
getType: CUSTOM Content-Type: text/event-plain Event-Name: PRESENCE_IN
getType: CUSTOM Content-Type: text/event-plain Event-Name: CHANNEL_STATE
getType: CUSTOM Content-Type: text/event-plain Event-Name: PRESENCE_IN
getType: CUSTOM Content-Type: text/event-plain Event-Name: CHANNEL_STATE
getType: CUSTOM Content-Type: text/event-plain Event-Name: CALL_UPDATE
getType: CUSTOM Content-Type: text/event-plain Event-Name: CHANNEL_PROGRESS
getType: CUSTOM Content-Type: text/event-plain Event-Name: CALL_UPDATE
getType: CUSTOM Content-Type: text/event-plain Event-Name: CODEC
getType: CUSTOM Content-Type: text/event-plain Event-Name: CODEC
getType: CUSTOM Content-Type: text/event-plain Event-Name: CHANNEL_ANSWER
getType: CUSTOM Content-Type: text/event-plain Event-Name: PRESENCE_IN
getType: CUSTOM Content-Type: text/event-plain Event-Name: API
getType: CUSTOM Content-Type: text/event-plain Event-Name: PRESENCE_IN
getType: CUSTOM Content-Type: text/event-plain Event-Name: CHANNEL_STATE
getType: CUSTOM Content-Type: text/event-plain Event-Name: CHANNEL_EXECUTE
getType: CUSTOM Content-Type: text/event-plain Event-Name: CHANNEL_PARK
getType: CHANNEL_EXECUTE Event-Name: CHANNEL_EXECUTE
getType: CHANNEL_HANGUP Event-Name: CHANNEL_HANGUP
getType: CHANNEL_EXECUTE_COMPLETE Event-Name: CHANNEL_EXECUTE_COMPLETE
getType: COMMAND Event-Name: COMMAND
getType: CHANNEL_UNPARK Event-Name: CHANNEL_UNPARK
getType: CHANNEL_EXECUTE_COMPLETE Event-Name: CHANNEL_EXECUTE_COMPLETE
getType: PRESENCE_IN Event-Name: PRESENCE_IN
getType: CHANNEL_STATE Event-Name: CHANNEL_STATE
getType: PRESENCE_IN Event-Name: PRESENCE_IN
getType: CHANNEL_HANGUP_COMPLETE Event-Name: CHANNEL_HANGUP_COMPLETE
getType: CHANNEL_STATE Event-Name: CHANNEL_STATE
getType: CHANNEL_DESTROY Event-Name: CHANNEL_DESTROY
getType: CHANNEL_STATE Event-Name: CHANNEL_STATE
Thanks, Ron
_______________________________________________ FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
What you are missing is that you are parsing the results incorrectly. The events that are showing up as CUSTOM only do so because the id of CUSTOM is 0 there are no types in the events received with recvEvent the are only used for transport. When you say "events plain all" you are asking for events to be delivered, the FS events are not the same as the events you are using to communicate at the lowest level. What you should be doing is checking for content-type of text/event-plain and then and only then, get the payload with getBody. This will contain a serialized event in it's entirety from FS. for clarity sake I have added a new event SOCKET_DATA to tree and from now on you will see those low level events with that type. On Sat, Jan 2, 2010 at 12:08 PM, Alberto Escudero <aep.lists@it46.se> wrote:
I do not know if really helps you but we are facing the same problem in one of our implementations using the ESL.so for PHP.
We have only see this problem when subscribing to the CHANNEL_STATE
getType() should always match EventName... but it does not ./aep
-- Stopping junk mailers is good for the environment
Would someone please take a look at this simple PHP event socket script and tell me what I am doing wrong - or tell me that this could be a bug elsewhere? Any help would be appreciated.
When I run the script without the call to execute(), everything seems fine. When I include the call to execute(), the calls to getType() return CUSTOM for a while, then later start to return the correct name.
#!/usr/bin/php <?php require_once 'ESL.php'; $endPoint = 'sofia/internal/695%192.168.100.132';
$eventSocket = New ESLconnection('192.168.100.132', '8021', 'ClueCon'); $event = $eventSocket->events('plain', 'ALL');
// call endpoint, get uuid $event = $eventSocket->api('originate', $endPoint . ' &park'); $serializedEvent = explode("\n", $event->serialize()); foreach ($serializedEvent as $eventLine) { list($dummy, $uuid) = explode('+OK ', $eventLine); if ($uuid) { break; } }
// play announcement to endpoint $event = $eventSocket->execute('playback', '/opt/ann/user-busy.wav', $uuid);
// monitor events while (TRUE) { echo "getType: " . $event->getType() . "\n"; $serializedEvent = explode("\n", $event->serialize()); foreach ($serializedEvent as $eventLine) { list($header, $value) = explode(': ', $eventLine); if ($header == "Event-Name") { printf($eventLine . "\n"); } if ($header == "Content-Type") { printf($eventLine . "\n"); } }
printf("\n"); $event = $eventSocket->recvEvent(); }?>
Run without the call to execute(): ================================== getType: CUSTOM Content-Type: api/response
getType: CHANNEL_CREATE Event-Name: CHANNEL_CREATE
getType: CHANNEL_OUTGOING Event-Name: CHANNEL_OUTGOING
getType: CHANNEL_ORIGINATE Event-Name: CHANNEL_ORIGINATE
getType: CHANNEL_STATE Event-Name: CHANNEL_STATE
getType: PRESENCE_IN Event-Name: PRESENCE_IN
getType: CHANNEL_STATE Event-Name: CHANNEL_STATE
getType: PRESENCE_IN Event-Name: PRESENCE_IN
getType: CHANNEL_STATE Event-Name: CHANNEL_STATE
getType: CALL_UPDATE Event-Name: CALL_UPDATE
getType: CHANNEL_PROGRESS Event-Name: CHANNEL_PROGRESS
getType: HEARTBEAT Event-Name: HEARTBEAT
getType: HEARTBEAT Event-Name: RE_SCHEDULE
getType: CALL_UPDATE Event-Name: CALL_UPDATE
getType: CODEC Event-Name: CODEC
getType: CODEC Event-Name: CODEC
getType: CHANNEL_ANSWER Event-Name: CHANNEL_ANSWER
getType: PRESENCE_IN Event-Name: PRESENCE_IN
getType: API Event-Name: API
getType: PRESENCE_IN Event-Name: PRESENCE_IN
getType: CHANNEL_STATE Event-Name: CHANNEL_STATE
getType: CHANNEL_EXECUTE Event-Name: CHANNEL_EXECUTE
getType: CHANNEL_PARK Event-Name: CHANNEL_PARK
getType: CHANNEL_HANGUP Event-Name: CHANNEL_HANGUP
getType: CHANNEL_UNPARK Event-Name: CHANNEL_UNPARK
getType: CHANNEL_EXECUTE_COMPLETE Event-Name: CHANNEL_EXECUTE_COMPLETE
getType: PRESENCE_IN Event-Name: PRESENCE_IN
getType: CHANNEL_STATE Event-Name: CHANNEL_STATE
getType: PRESENCE_IN Event-Name: PRESENCE_IN
getType: CHANNEL_HANGUP_COMPLETE Event-Name: CHANNEL_HANGUP_COMPLETE
getType: CHANNEL_STATE Event-Name: CHANNEL_STATE
getType: CHANNEL_DESTROY Event-Name: CHANNEL_DESTROY
getType: CHANNEL_STATE Event-Name: CHANNEL_STATE
Run with the call to execute(): =============================== getType: CUSTOM Content-Type: command/reply
getType: CUSTOM Content-Type: text/event-plain Event-Name: CHANNEL_CREATE
getType: CUSTOM Content-Type: text/event-plain Event-Name: CHANNEL_OUTGOING
getType: CUSTOM Content-Type: text/event-plain Event-Name: CHANNEL_ORIGINATE
getType: CUSTOM Content-Type: text/event-plain Event-Name: CHANNEL_STATE
getType: CUSTOM Content-Type: text/event-plain Event-Name: PRESENCE_IN
getType: CUSTOM Content-Type: text/event-plain Event-Name: CHANNEL_STATE
getType: CUSTOM Content-Type: text/event-plain Event-Name: PRESENCE_IN
getType: CUSTOM Content-Type: text/event-plain Event-Name: CHANNEL_STATE
getType: CUSTOM Content-Type: text/event-plain Event-Name: CALL_UPDATE
getType: CUSTOM Content-Type: text/event-plain Event-Name: CHANNEL_PROGRESS
getType: CUSTOM Content-Type: text/event-plain Event-Name: CALL_UPDATE
getType: CUSTOM Content-Type: text/event-plain Event-Name: CODEC
getType: CUSTOM Content-Type: text/event-plain Event-Name: CODEC
getType: CUSTOM Content-Type: text/event-plain Event-Name: CHANNEL_ANSWER
getType: CUSTOM Content-Type: text/event-plain Event-Name: PRESENCE_IN
getType: CUSTOM Content-Type: text/event-plain Event-Name: API
getType: CUSTOM Content-Type: text/event-plain Event-Name: PRESENCE_IN
getType: CUSTOM Content-Type: text/event-plain Event-Name: CHANNEL_STATE
getType: CUSTOM Content-Type: text/event-plain Event-Name: CHANNEL_EXECUTE
getType: CUSTOM Content-Type: text/event-plain Event-Name: CHANNEL_PARK
getType: CHANNEL_EXECUTE Event-Name: CHANNEL_EXECUTE
getType: CHANNEL_HANGUP Event-Name: CHANNEL_HANGUP
getType: CHANNEL_EXECUTE_COMPLETE Event-Name: CHANNEL_EXECUTE_COMPLETE
getType: COMMAND Event-Name: COMMAND
getType: CHANNEL_UNPARK Event-Name: CHANNEL_UNPARK
getType: CHANNEL_EXECUTE_COMPLETE Event-Name: CHANNEL_EXECUTE_COMPLETE
getType: PRESENCE_IN Event-Name: PRESENCE_IN
getType: CHANNEL_STATE Event-Name: CHANNEL_STATE
getType: PRESENCE_IN Event-Name: PRESENCE_IN
getType: CHANNEL_HANGUP_COMPLETE Event-Name: CHANNEL_HANGUP_COMPLETE
getType: CHANNEL_STATE Event-Name: CHANNEL_STATE
getType: CHANNEL_DESTROY Event-Name: CHANNEL_DESTROY
getType: CHANNEL_STATE Event-Name: CHANNEL_STATE
Thanks, Ron
_______________________________________________ FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
_______________________________________________ FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
-- Anthony Minessale II FreeSWITCH http://www.freeswitch.org/ ClueCon http://www.cluecon.com/ Twitter: http://twitter.com/FreeSWITCH_wire AIM: anthm MSN:anthony_minessale@hotmail.com <MSN%3Aanthony_minessale@hotmail.com> GTALK/JABBER/PAYPAL:anthony.minessale@gmail.com<PAYPAL%3Aanthony.minessale@gmail.com> IRC: irc.freenode.net #freeswitch FreeSWITCH Developer Conference sip:888@conference.freeswitch.org <sip%3A888@conference.freeswitch.org> iax:guest@conference.freeswitch.org/888 googletalk:conf+888@conference.freeswitch.org<googletalk%3Aconf%2B888@conference.freeswitch.org> pstn:+19193869900
participants (3)
-
Alberto Escudero
-
Anthony Minessale
-
Ron McLeod