} /* If we reached here we should have a valid object */ switch ($ev->type) { case "incoming": switch ($ev->name) { case "engine.timer": $ev->Acknowledge(); runDtmfTimer($ev->origin); runCallTimer($ev->origin); $ev = false; break; case "chan.startup": onStartup($ev, $ev->GetValue("id")); break; case "chan.hangup": onHangup($ev, $ev->GetValue("id")); break; case "call.answered": onAnswer($ev, $ev->GetValue("id"), $ev->origin); break; } /* This is extremely important. We MUST let messages return, handled or not */ if ($ev) { $ev->Acknowledge(); } break; case "answer": // Yate::Debug("PHP Answered: " . $ev->name . " id: " . $ev->id); break; case "installed":
$ourcallid = $ev->GetValue("id"); $callto = $ev->GetValue("real_callto"); if ($ourcallid && $callto) { // Put back the real callto and let the message flow $ev->params["callto"] = $callto; Yate::Install("chan.hangup", 75, "id", $ourcallid); Yate::Install("chan.disconnected", 75, "id", $ourcallid); onStartup($ev); } else { Yate::Output("Invalid assist: '{$ourcallid}' -> '{$callto}'"); $ourcallid = false; } break; case "chan.hangup": // We were hung up. Do any cleanup and exit. onHangup($ev); $ourcallid = false; break; case "chan.disconnected": // Our party disconnected and we're ready to hang up. // We should reconnect before this message is acknowledged if (onDisconnect($ev, $ev->GetValue("reason"))) { $ev->handled = true; } break; } /* This is extremely important. We MUST let messages return, handled or not */ if ($ev !== false) { $ev->Acknowledge(); }