Exemplo n.º 1
0
function callInitiate($target, $ev)
{
    Yate::Debug("Initiating dialout call to '{$target}'");
    $m = new Yate("call.execute");
    $m->id = "";
    $m->SetParam("callto", "external/nodata/dialout-dialer.php");
    $m->SetParam("direct", $target);
    $m->SetParam("caller", $ev->GetValue("caller"));
    $m->SetParam("callername", $ev->GetValue("callername"));
    $m->SetParam("called", $ev->GetValue("called"));
    $m->Dispatch();
}
Exemplo n.º 2
0
function onDisconnect(&$ev, $reason)
{
    global $ourcallid;
    Yate::Output("Channel {$ourcallid} was disconnected, reason: '{$reason}'");
    // Sample action: redirect to info tone if user is busy
    if ($reason == "busy") {
        $m = new Yate("call.execute");
        $m->id = $ev->id;
        $m->SetParam("id", $ourcallid);
        $m->SetParam("callto", "tone/info");
        $m->Dispatch();
        // Also send progressing so the tone goes through in early media
        $m = new Yate("call.progress");
        $m->SetParam("targetid", $ourcallid);
        $m->Dispatch();
        return true;
    }
    return false;
}
Exemplo n.º 3
0
function callInitiate($target, $ev)
{
    Yate::Debug("Initiating dialout call to '{$target}'");
    $m = new Yate("call.execute");
    $m->params = $ev->params;
    $m->id = "";
    $m->SetParam("callto", "external/nodata/ctc-dialer.php");
    $m->SetParam("direct", $target);
    $m->SetParam("caller", $ev->GetValue("real_called"));
    $m->SetParam("call_from", $ev->GetValue("call_from"));
    $m->SetParam("called", $ev->GetValue("real_caller"));
    $m->SetParam("cdrtrack", "true");
    $m->Dispatch();
}
Exemplo n.º 4
0
function secondCall($route, $ev)
{
    global $partycallid;
    global $real_called;
    global $billid;
    global $callFrom;
    // global $place;
    //$real_caller = '79297333104';
    $m = new Yate("chan.masquerade");
    $m->params = $ev->params;
    $m->SetParam("message", "call.execute");
    $m->SetParam("callto", $route);
    //$m->SetParam("caller", $real_caller);
    $m->SetParam("called", $real_called);
    $m->SetParam("id", $partycallid);
    $m->SetParam("billid", $billid);
    $m->SetParam("call_from", $callFrom);
    $m->Dispatch();
}
Exemplo n.º 5
0
// Always the first action to do
Yate::Init();
if ($debug_on) {
    Yate::Debug(true);
    Yate::Output(true);
}
if (Yate::Arg()) {
    Yate::Output("Executing startup time CDR cleanup");
    $query = "UPDATE call_logs SET ended= 1 where ended = 0 or ended IS NULL";
    query_nores($query);
    $query = "UPDATE extensions SET inuse_count=0";
    query_nores($query);
    // Spawn another, restartable instance
    $cmd = new Yate("engine.command");
    $cmd->id = "";
    $cmd->SetParam("line", "external register.php");
    $cmd->Dispatch();
    sleep(1);
    exit;
}
// Install handler for the wave end notify messages
Yate::Watch("engine.timer");
Yate::Install("user.register");
Yate::Install("user.unregister");
Yate::Install("user.auth");
Yate::Install("call.route");
Yate::Install("call.cdr");
Yate::Install("call.answered", 50);
Yate::Install("chan.disconnected", 50);
Yate::Install("chan.hangup");
Yate::Install("user.notify");
Exemplo n.º 6
0
function callAnswered()
{
    global $ourcallid;
    global $prompt;
    global $done;
    Yate::Debug("callAnswered");
    if ($prompt != "") {
        $m = new Yate("chan.attach");
        $m->id = "";
        $m->SetParam("id", $ourcallid);
        $m->SetParam("source", $prompt);
        $m->SetParam("single", true);
        $m->SetParam("notify", $ourcallid);
        $m->Dispatch();
    } else {
        $done = true;
    }
}
Exemplo n.º 7
0
 /**
  * Emit a DTMF to the other end
  * @param $dtmf DTMF tones to play
  * @param $method Method to emit the DTMF, null to use technology default
  */
 function PlayDTMF($dtmf, $method = null)
 {
     $m = new Yate("chan.dtmf");
     $m->id = "";
     $m->SetParam("id", IVR::ChannelID());
     $m->SetParam("targetid", IVR::TargetID());
     $m->SetParam("text", $dtmf);
     if ($method !== null) {
         $m->SetParam("method", $method);
     }
     $m->Dispatch();
 }
Exemplo n.º 8
0
        continue;
    }
    $id = $ev->GetValue("peerid");
    if ($ev->type == "incoming") {
        if ($ev->GetValue("earlymedia") == "false" && $ev->GetValue("rtp_forward") != "yes") {
            Yate::Debug("Preparing fake {$mediafmt} ringback to {$id}");
            $ev->SetParam("earlymedia", true);
            $ev->SetParam("formats", $mediafmt);
            $ev->SetParam("ringback", $ringback);
        }
        $ev->Acknowledge();
    } else {
        if ($ev->type == "answer") {
            if ($ev->handled) {
                $ring = $ev->GetValue("ringback");
                if ($id != "" && $ring != "") {
                    Yate::Debug("Faking ringback {$ring} to {$id}");
                    $m = new Yate("chan.masquerade");
                    $m->id = "";
                    $m->SetParam("message", "chan.attach");
                    $m->SetParam("id", $id);
                    $m->SetParam("replace", $ring);
                    $m->SetParam("autorepeat", true);
                    $m->SetParam("single", true);
                    $m->Dispatch();
                }
            }
        }
    }
}
/* vi: set ts=8 sw=4 sts=4 noet: */