-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVoipMonitor.php
70 lines (63 loc) · 2.08 KB
/
VoipMonitor.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php
/**
* VoIP Monitor Deamon
*
* @package VoipMonitor
* @license http://www.gnu.org/licenses/agpl.html AGPL Version 3
* @copyright Copyright (c) 2010 Metaways Infosystems GmbH (http://www.metaways.de)
* @author Lars Kneschke <l.kneschke@metaways.de>
* @version $Id: Exception.php 5149 2008-10-29 12:07:26Z p.schuele@metaways.de $
*/
/**
* VoIP Monitor Deamon
*
* @package VoipMonitor
*/
class VoipMonitor extends VoipMonitor_Daemon
{
protected $_frontend;
protected $_frontendName;
protected $_frontendConfig;
protected $_backendConfig;
/**
* constructor
*
* @param Zend_Config $_config the Zend_Config object
* @param bool $_becomeDaemon if true forks to background
*/
public function __construct(Zend_Config $_config, $_becomeDaemon = false)
{
foreach($_config as $section => $config) {
$sectionUc = ucfirst(strtolower($section));
if(is_null($this->_frontendConfig) && @class_exists('VoipMonitor_Frontend_' . $sectionUc)) {
$this->_frontendName = $sectionUc;
$this->_frontendConfig = $config;
} elseif(strtolower($section) == 'tine20') {
$this->_backendConfig = $config;
}
}
parent::__construct($_becomeDaemon);
}
/**
* (non-PHPdoc)
* @see VoipMonitor/VoipMonitor_Daemon#run()
*/
public function run()
{
$this->_frontend = VoipMonitor_Frontend_Factory::factory($this->_frontendName, $this->_frontendConfig);
$this->_backend = VoipMonitor_Backend_Factory::factory('Tine20', $this->_backendConfig);
$this->_frontend->attach($this->_backend);
$this->_frontend->handleEvents();
}
/**
* (non-PHPdoc)
* @see VoipMonitor/VoipMonitor_Daemon#handleSigTERM($signal)
*/
public function handleSigTERM($signal)
{
echo "Caught SigTERM/INT... " . PHP_EOL;
$this->_frontend->stopHandleEvents();
$this->_backend->logout();
//exit();
}
}