}
}
$log->addLogger(
- new Logger_CallEcho(), array('incomingCall', 'finishedCall')
+ new Logger_CallEcho(), array('startingCall', 'finishedCall')
);
$callMonitor = new CallMonitor($this->config, $log);
{
$call = $this->currentCalls[$callId];
$call->start = time();
+ if ($msg->tei == 127) {
+ $call->type = CallMonitor_Call::INCOMING;
+ } else {
+ $call->type = CallMonitor_Call::OUTGOING;
+ }
+
$this->handleParams($call, $msg);
}
$this->handleParams($call, $msg);
break;
case EDSS1_Message::CALL_PROCEEDING:
- $this->log->log('incomingCall', array('call' => $call));
+ $this->log->log('startingCall', array('call' => $call));
break;
case EDSS1_Message::RELEASE:
class CallMonitor_Call
{
+ const INCOMING = 'i';
+ const OUTGOING = 'o';
+
+ /**
+ * Type of call: "i"ncoming or "o"utgoing
+ *
+ * @var string
+ */
+ public $type;
+
+
/**
* Telephone number of caller
*
protected $logger = array(
'msgData' => array(),
'edss1msg' => array(),
- 'incomingCall' => array(),
+ 'startingCall' => array(),
'finishedCall' => array(),
);
public function log($type, $arData)
{
switch ($type) {
- case 'incomingCall':
- $this->displayIncoming($arData['call']);
+ case 'startingCall':
+ $this->displayStart($arData['call']);
break;
case 'finishedCall':
$this->displayFinished($arData['call']);
}
- protected function displayIncoming(CallMonitor_Call $call)
+ protected function displayStart(CallMonitor_Call $call)
{
- echo 'Incoming call from ' . $call->from
+ echo 'Starting ' . $this->getTypeName($call)
+ . ' call from ' . $call->from
. ' to ' . $call->to . "\n";
}
protected function displayFinished(CallMonitor_Call $call)
{
- echo 'Finished call from ' . $call->from
+ echo 'Finished ' . $this->getTypeName($call)
+ . ' call from ' . $call->from
. ' to ' . $call->to
. ', length ' . date('H:i:s', $call->end - $call->start - 3600)
. "\n";
}
+
+ protected function getTypeName($call)
+ {
+ return $call->type == CallMonitor_Call::INCOMING
+ ? 'incoming' : 'outgoing';
+ }
}
?>