Exemple #1
0
 /**
  * Perform the transfer
  *
  * @return boolean
  * @throws RuntimeException
  */
 public function transfer()
 {
     if (!isset($this->_options[self::OPT_TRANSFER_DESTINATION])) {
         throw new RuntimeException('Transfer destination has not been provided');
     }
     if (!$this->_sipCallLeg->isAlive()) {
         $this->dispatchErrorEvent(self::DEAD_CALL_LEG_ERR_CODE);
         return false;
     }
     if ($this->isTransferring()) {
         $this->dispatchErrorEvent(self::ALREADY_TRANSFERRING_ERR_CODE);
         return false;
     }
     $params = array('number' => $this->_options[self::OPT_TRANSFER_DESTINATION]);
     $headers = $this->_options[self::OPT_TRANSFER_HEADERS];
     if (!empty($headers)) {
         foreach ($headers as $name => $value) {
             $params[$name] = $value;
         }
     }
     $transferSignal = Streamwide_Engine_Signal::factory(Streamwide_Engine_Signal::TRANSFER, $this->_sipCallLeg->getName(), $params);
     if (false === $transferSignal->send()) {
         $this->dispatchErrorEvent(self::TRANSFER_SIGNAL_SEND_ERR_CODE);
         return false;
     }
     $this->_subscribeToEngineEvents();
     $this->_stateManager->setState(self::STATE_TRANSFERRING);
     return true;
 }
Exemple #2
0
 /**
  * Set the call leg that will replace the call leg that is expected to generate the TRANSFER
  * request
  *
  * @param Streamwide_Engine_Sip_Call_Leg $transferDestination
  * @return void
  * @throws InvalidArgumentException
  */
 public function setTransferDestination(Streamwide_Engine_Sip_Call_Leg $transferDestination)
 {
     if ($transferDestination->isAlive()) {
         throw new InvalidArgumentException(__METHOD__ . ' expects parameter 1 to be a dead SIP call leg');
     }
     $this->_transferDestination = $transferDestination;
 }
Exemple #3
0
 /**
  * Make sure that both the SIP call legs are alive
  *
  * @return boolean
  */
 protected function _ensureAliveCallLegs()
 {
     if ($this->_leftCallLeg->isAlive() && $this->_rightCallLeg->isAlive()) {
         return true;
     }
     $this->dispatchErrorEvent(self::DEAD_CALL_LEG_ERR_CODE);
     return false;
 }