当前位置: 首页>>代码示例>>PHP>>正文


PHP AGI_AsteriskManager::add_event_handler方法代码示例

本文整理汇总了PHP中AGI_AsteriskManager::add_event_handler方法的典型用法代码示例。如果您正苦于以下问题:PHP AGI_AsteriskManager::add_event_handler方法的具体用法?PHP AGI_AsteriskManager::add_event_handler怎么用?PHP AGI_AsteriskManager::add_event_handler使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AGI_AsteriskManager的用法示例。


在下文中一共展示了AGI_AsteriskManager::add_event_handler方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: get_agent_status

function get_agent_status($queue, $agent)
{
    global $queue_members;
    # Connect to AGI
    $asm = new AGI_AsteriskManager();
    $asm->connect();
    # Add event handlers to retrieve the answer
    $asm->add_event_handler('queuestatuscomplete', 'Aastra_asm_event_queues_Asterisk');
    $asm->add_event_handler('queuemember', 'Aastra_asm_event_agents_Asterisk');
    # Retrieve info
    while (!$queue_members) {
        $asm->QueueStatus();
        $count++;
        if ($count == 10) {
            break;
        }
    }
    # Get info for the given queue
    $status['Logged'] = False;
    $status['Paused'] = False;
    foreach ($queue_members as $agent_a) {
        if ($agent_a['Queue'] == $queue && $agent_a['Location'] == 'Local/' . $agent . '@from-queue/n' or $agent_a['Queue'] == $queue && $agent_a['Location'] == 'Local/' . $agent . '@from-internal/n') {
            $status['Logged'] = True;
            if ($agent_a['Paused'] == '1') {
                $status['Paused'] = True;
            }
            $status['Type'] = $agent_a['Membership'];
            $status['CallsTaken'] = $agent_a['CallsTaken'];
            $status['LastCall'] = $agent_a['LastCall'];
            break;
        }
        # Get Penalty
        $penalty = $asm->database_get('QPENALTY', $queue . '/agents/' . $agent);
        if ($penalty == '') {
            $penalty = '0';
        }
        $status['Penalty'] = $penalty;
    }
    # Disconnect properly
    $asm->disconnect();
    # Return Status
    return $status;
}
开发者ID:jamesrusso,项目名称:Aastra_Scripts,代码行数:43,代码来源:queues.php

示例2: array

         $as->debug = true;
     }
 }
 // && CONNECTING  connect($server=NULL, $username=NULL, $secret=NULL)
 $res = $as->connect($host, $uname, $password);
 if (!$res) {
     echo str_params(_("Cannot connect to asterisk manager @%1. Please check manager configuration...\n"), array($host), 1);
     sleep(60);
     continue;
 }
 if ($verbose > 2) {
     echo "Connected to asterisk.\n";
 }
 //$res = $as->Ping();
 $as->Events('agent,call');
 $as->add_event_handler('Join', handle_handler);
 $as->add_event_handler('Leave', idle_handler);
 $as->add_event_handler('QueueCallerAbandon', handle_handler);
 $as->add_event_handler('AgentCalled', handle_handler);
 $as->add_event_handler('AgentDump', handle_handler);
 $as->add_event_handler('AgentConnect', handle_handler);
 $as->add_event_handler('AgentComplete', handle_handler);
 $as->add_event_handler('QueueMemberRemoved', handle_handler);
 $as->add_event_handler('QueueMemberAdded', handle_handler);
 $as->add_event_handler('QueueMemberPaused', handle_handler);
 $as->add_event_handler('QueueMemberStatus', idle_handler);
 $as->add_event_handler('*', idle_handler);
 while ($res = $as->send_request('WaitEvent')) {
     if ($verbose > 1) {
         echo "WaitEvent: " . $res['Response'] . "\n";
     }
开发者ID:sayemk,项目名称:a2billing,代码行数:31,代码来源:manager-eventd.php

示例3: Aastra_get_queue_entries_Asterisk

function Aastra_get_queue_entries_Asterisk($queue)
{
    global $queue_entries;
    # Connect to AGI
    $asm = new AGI_AsteriskManager();
    $asm->connect();
    # Add event handlers to retrieve the answer
    $asm->add_event_handler('queuestatuscomplete', 'Aastra_asm_event_queues_asterisk');
    $asm->add_event_handler('queueentry', 'Aastra_asm_event_entries_Asterisk');
    # Retrieve info
    $count = 0;
    while (!$queue_entries) {
        $asm->QueueStatus();
        $count++;
        if ($count == 10) {
            break;
        }
    }
    # Process info
    $index = 0;
    if (count($queue_entries) > 0) {
        foreach ($queue_entries as $entry) {
            if ($entry['Queue'] == $queue) {
                $entries[$index] = $entry;
                $index++;
            }
        }
    }
    # Disconnect properly
    $asm->disconnect();
    # Return Status
    if (isset($entries)) {
        return $entries;
    } else {
        return NULL;
    }
}
开发者ID:jamesrusso,项目名称:Aastra_Scripts,代码行数:37,代码来源:AastraAsterisk.php

示例4: date

    }
}
if (!$amihost) {
    echo date('Y-m-d H:i:s') . " : AMI is not configured. No need to run cycle\n";
    exit;
}
echo date("Y-m-d H:i:s") . " running " . basename(__FILE__) . PHP_EOL;
include './lib/phpagi/phpagi-asmanager.php';
$manager = new AGI_AsteriskManager();
echo date('Y-m-d H:i:s') . " : Connecting to AMI... ";
if (!$manager->connect($amihost . ":" . $amiport, $amiusername, $amipassword)) {
    echo " ...Connection failed.\n";
    exit;
} else {
    echo " ...Connection established.\n";
    $manager->add_event_handler('*', 'dump_events');
}
$manager->wait_response();
$latest_check = 0;
$checkEvery = 10;
// poll every 1 seconds
while ($manager->Ping()) {
    if (time() - $latest_check > $checkEvery) {
        setGlobal(str_replace('.php', '', basename(__FILE__)) . 'Run', time(), 1);
        $latest_check = time();
    }
    if (file_exists('./reboot') || isset($_GET['onetime'])) {
        $manager->disconnect();
        $db->Disconnect();
        exit;
    }
开发者ID:szolenko,项目名称:app_asterisk,代码行数:31,代码来源:cycle_asterisk.php

示例5: is_agent_logged

function is_agent_logged($agent)
{
    global $queue_members;
    $queue_members = '';
    # Transcode for device and user mode
    $agent = Aastra_get_userdevice_Asterisk($agent);
    # Not logged by default
    $return = False;
    # Connect to AGI
    $asm = new AGI_AsteriskManager();
    $asm->connect();
    # Add event handlers to retrieve the answer
    $asm->add_event_handler('queuestatuscomplete', 'asm_event_queues');
    $asm->add_event_handler('queuemember', 'asm_event_agents');
    # Retrieve info
    while (!$queue_members) {
        $asm->QueueStatus();
        $count++;
        if ($count == 10) {
            break;
        }
    }
    # Get info for all the queues
    foreach ($queue_members as $agent_a) {
        if ($agent_a['Location'] == 'Local/' . $agent . '@from-queue/n' or $agent_a['Location'] == 'Local/' . $agent . '@from-internal/n') {
            $return = True;
            break;
        }
    }
    # Disconnect properly
    $asm->disconnect();
    # Return Status
    return $return;
}
开发者ID:jamesrusso,项目名称:Aastra_Scripts,代码行数:34,代码来源:agent.php


注:本文中的AGI_AsteriskManager::add_event_handler方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。