Ignore the "replaced" notifies. Use the more efficient filtered handlers.
git-svn-id: http://voip.null.ro/svn/yate@1223 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
parent
4f6688f5b3
commit
782a6327b4
|
@ -11,8 +11,8 @@ require_once("libvoicemail.php");
|
|||
/* Always the first action to do */
|
||||
Yate::Init();
|
||||
|
||||
/* Install handler for the wave end notify messages */
|
||||
Yate::Install("chan.notify");
|
||||
/* Uncomment next line to get debugging messages */
|
||||
//Yate::Debug(true);
|
||||
|
||||
$ourcallid = "leavemail/" . uniqid(rand(),1);
|
||||
$partycallid = "";
|
||||
|
@ -51,7 +51,7 @@ function setState($newstate)
|
|||
if ($state == "")
|
||||
return;
|
||||
|
||||
Yate::Output("setState('$newstate') state: $state");
|
||||
Yate::Debug("setState('$newstate') state: $state");
|
||||
|
||||
if ($newstate == $state)
|
||||
return;
|
||||
|
@ -103,11 +103,13 @@ function setState($newstate)
|
|||
}
|
||||
|
||||
/* Handle EOF of wave files */
|
||||
function gotNotify()
|
||||
function gotNotify($reason)
|
||||
{
|
||||
global $state;
|
||||
|
||||
Yate::Output("gotNotify() state: $state");
|
||||
Yate::Debug("gotNotify('$reason') state: $state");
|
||||
if ($reason == "replaced")
|
||||
return;
|
||||
|
||||
switch ($state) {
|
||||
case "goodbye":
|
||||
|
@ -125,6 +127,9 @@ function gotNotify()
|
|||
}
|
||||
}
|
||||
|
||||
/* Install filtered handler for the wave end notify messages */
|
||||
Yate::Install("chan.notify","targetid",$ourcallid);
|
||||
|
||||
/* The main loop. We pick events and handle them */
|
||||
while ($state != "") {
|
||||
$ev=Yate::GetEvent();
|
||||
|
@ -162,10 +167,8 @@ while ($state != "") {
|
|||
break;
|
||||
|
||||
case "chan.notify":
|
||||
if ($ev->GetValue("targetid") == $ourcallid) {
|
||||
gotNotify();
|
||||
$ev->handled = true;
|
||||
}
|
||||
gotNotify($ev->GetValue("reason"));
|
||||
$ev->handled = true;
|
||||
break;
|
||||
}
|
||||
/* This is extremely important.
|
||||
|
|
|
@ -13,9 +13,8 @@ require_once("libvoicemail.php");
|
|||
/* Always the first action to do */
|
||||
Yate::Init();
|
||||
|
||||
/* Install handlers for the wave end and dtmf notify messages */
|
||||
Yate::Install("chan.dtmf");
|
||||
Yate::Install("chan.notify");
|
||||
/* Uncomment next line to get debugging messages */
|
||||
//Yate::Debug(true);
|
||||
|
||||
$ourcallid = "voicemail/" . uniqid(rand(),1);
|
||||
$partycallid = "";
|
||||
|
@ -209,13 +208,15 @@ function checkAuth($pass)
|
|||
}
|
||||
|
||||
/* Handle EOF of wave files */
|
||||
function gotNotify()
|
||||
function gotNotify($reason)
|
||||
{
|
||||
global $ourcallid;
|
||||
global $partycallid;
|
||||
global $state;
|
||||
|
||||
Yate::Debug("gotNotify() state: $state");
|
||||
Yate::Debug("gotNotify('$reason') state: $state");
|
||||
if ($reason == "replaced")
|
||||
return;
|
||||
|
||||
switch ($state) {
|
||||
case "goodbye":
|
||||
|
@ -320,6 +321,10 @@ function gotDTMF($text)
|
|||
navigate($text);
|
||||
}
|
||||
|
||||
/* Install filtered handlers for the wave end and dtmf notify messages */
|
||||
Yate::Install("chan.dtmf","targetid",$ourcallid);
|
||||
Yate::Install("chan.notify","targetid",$ourcallid);
|
||||
|
||||
/* The main loop. We pick events and handle them */
|
||||
while ($state != "") {
|
||||
$ev=Yate::GetEvent();
|
||||
|
@ -357,19 +362,15 @@ while ($state != "") {
|
|||
break;
|
||||
|
||||
case "chan.notify":
|
||||
if ($ev->GetValue("targetid") == $ourcallid) {
|
||||
gotNotify();
|
||||
$ev->handled = true;
|
||||
}
|
||||
gotNotify($ev->GetValue("reason"));
|
||||
$ev->handled = true;
|
||||
break;
|
||||
|
||||
case "chan.dtmf":
|
||||
if ($ev->GetValue("targetid") == $ourcallid ) {
|
||||
$text = $ev->GetValue("text");
|
||||
for ($i = 0; $i < strlen($text); $i++)
|
||||
gotDTMF($text[$i]);
|
||||
$ev->handled = true;
|
||||
}
|
||||
$text = $ev->GetValue("text");
|
||||
for ($i = 0; $i < strlen($text); $i++)
|
||||
gotDTMF($text[$i]);
|
||||
$ev->handled = true;
|
||||
break;
|
||||
}
|
||||
/* This is extremely important.
|
||||
|
|
Loading…
Reference in New Issue