#!/usr/bin/php -q id = ""; $m->SetParam("id",$ourcallid); $m->SetParam("source",$prompt); $m->SetParam("single",true); $m->SetParam("notify",$ourcallid); $m->Dispatch(); } else $done = true; } Yate::SetLocal("id",$ourcallid); Yate::SetLocal("disconnected","true"); Yate::Install("chan.disconnected",90,"id",$ourcallid); // The main loop. We pick events and handle them while ($running) { $ev=Yate::GetEvent(); if ($ev === false) break; if ($ev === true) continue; switch ($ev->type) { case "incoming": switch ($ev->name) { case "call.execute": $caller = $ev->GetValue("caller"); $callername = $ev->GetValue("callername"); $called = $ev->GetValue("called"); $ev->handled = true; // Dispatch outgoing call.execute before acknowledging this one $m = new Yate("call.execute"); $m->SetParam("id",$ourcallid); $m->SetParam("callto",$ev->GetValue("direct")); $m->SetParam("caller",$caller); $m->SetParam("callername",$callername); $m->SetParam("called",$called); // No need to track us, this is an utility channel $m->SetParam("cdrtrack",false); // Active DTMF detector on outgoing call leg $m->SetParam("tonedetect_out",true); $m->Dispatch(); break; case "call.answered": callAnswered(); $ev->handled = true; break; case "chan.notify": callFailed("noanswer"); $ev->handled = true; break; case "chan.dtmf": gotDTMF($ev->GetValue("text")); $ev->handled = true; break; case "chan.disconnected": callFailed($ev->GetValue("reason")); /* Put it back running to avoid double destruction... */ $running = true; $ev->handled = true; break; } /* This is extremely important. We MUST let messages return, handled or not */ if ($ev) $ev->Acknowledge(); break; case "answer": if ($ev->name == "call.execute") { if ($ev->handled) { callExecuting($ev->GetValue("peerid")); continue; } callFailed($ev->GetValue("error"),$ev->GetValue("reason")); } break; default: Yate::Debug("PHP Event: " . $ev->type); } } Yate::Debug("PHP: bye!"); /* vi: set ts=8 sw=4 sts=4 noet: */ ?>