/** * @param Streamwide_Engine_Call_Leg_Abstract $callLeg * @return void * @throws InvalidArgumentException */ public function setCallLeg(Streamwide_Engine_Call_Leg_Abstract $callLeg) { if ($callLeg->isAlive()) { throw new InvalidArgumentException(get_class($this) . '::' . __FUNCTION__ . ' expects parameter 1 to be a dead call leg'); } $this->_callLeg = $callLeg; }
/** * Set the call leg to be put on hold. * * @param Streamwide_Engine_Call_Leg_Abstract $callLeg * @return void */ public function setCallLeg(Streamwide_Engine_Call_Leg_Abstract $callLeg) { if (!$callLeg instanceof Streamwide_Engine_Sip_Call_Leg) { throw new InvalidArgumentException(__METHOD__ . ' expects parameter 1 to be an instanceof Streamwide_Engine_Sip_Call_Leg'); } if (!$callLeg->isAlive()) { throw new InvalidArgumentException(__METHOD__ . ' requires parameter 1 to be an alive call leg'); } if (!$callLeg->hasSentOrReceivedOk()) { throw new InvalidArgumentException(__METHOD__ . ' requires parameter 1 to be a call leg that has sent or received the OK signal'); } $this->_callLeg = $callLeg; }
/** * Kills a call leg * * @param Streamwide_Engine_Call_Leg_Abstract $callLeg * @param boolean $force * @return boolean */ public function kill(Streamwide_Engine_Call_Leg_Abstract $callLeg, $force = false) { if (false === $force && !$callLeg->isAlive()) { $this->dispatchErrorEvent(self::CALL_LEG_NOT_ALIVE_ERR_CODE); return false; } $callLegName = $callLeg->getName(); $signal = Streamwide_Engine_Signal::factory(Streamwide_Engine_Signal::KILL, $callLegName); if (false === $signal->send()) { $this->dispatchErrorEvent(self::KILL_SIGNAL_SEND_FAILURE_ERR_CODE); return false; } $callLeg->setDead(); $event = new Streamwide_Engine_Events_Event(Streamwide_Engine_Events_Event::SUCCESS); $event->setParam('callLeg', $callLeg); $this->dispatchEvent($event); return true; }
/** * Set the right SIP call leg * * @param Streamwide_Engine_Call_Leg_Abstract $rightCallLeg * @return void * @throws InvalidArgumentException */ public function setRightCallLeg(Streamwide_Engine_Call_Leg_Abstract $rightCallLeg) { if (!$rightCallLeg instanceof Streamwide_Engine_Sip_Call_Leg) { throw new InvalidArgumentException(__METHOD__ . ' requires parameter 1 to be an instance of Streamwide_Engine_Sip_Call_Leg'); } if (!$rightCallLeg->isAlive()) { throw new InvalidArgumentException(__METHOD__ . ' requires parameter 1 to be an alive SIP call leg'); } if (!$rightCallLeg->hasSentOrReceivedOk()) { throw new InvalidArgumentException(__METHOD__ . ' requires parameter 1 to be an alive SIP call leg that has received the OK signal'); } parent::setRightCallLeg($rightCallLeg); }
/** * Set the right call leg * * @param Streamwide_Engine_Call_Leg_Abstract $rightCallLeg * @return void * @throws InvalidArgumentException */ public function setRightCallLeg(Streamwide_Engine_Call_Leg_Abstract $rightCallLeg) { if (!$rightCallLeg instanceof Streamwide_Engine_Sip_Call_Leg) { throw new InvalidArgumentException(__METHOD__ . ' requires parameter 1 to be an instance of Streamwide_Engine_Sip_Call_Leg'); } if ($rightCallLeg->isAlive()) { throw new InvalidArgumentException(__METHOD__ . ' requires parameter 1 to be a dead SIP call leg'); } parent::setRightCallLeg($rightCallLeg); }
/** * Set the call leg that is currently linked with the call leg that is expected * to generate the TRANSFER request * * @param Streamwide_Engine_Call_Leg_Abstract $transferSourceLink * @return void * @throws InvalidArgumentException */ public function setTransferSourceLink(Streamwide_Engine_Call_Leg_Abstract $transferSourceLink) { if (!$transferSourceLink instanceof Streamwide_Engine_Sip_Call_Leg && !$transferSourceLink instanceof Streamwide_Engine_Media_Server_Call_Leg) { throw new InvalidArgumentException(__METHOD__ . ' expects parameter 1 to be a SIP or MS call leg'); } if (!$transferSourceLink->isAlive()) { throw new InvalidArgumentException(__METHOD__ . ' expects parameter 1 to be an alive SIP or MS call leg'); } $this->_transferSourceLink = $transferSourceLink; }
/** * Make sure that both of the call legs involved in the relaying process * 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; }