Пример #1
0
 /**
  * Swift's SendEvent listener.
  * Invoked when Swift sends a message
  * @param Swift_Events_SendEvent The event information
  * @throws Swift_ConnectionException If the connection cannot be rotated
  */
 public function sendPerformed(Swift_Events_SendEvent $e)
 {
     if (!method_exists($e->getSwift()->connection, "nextConnection")) {
         throw new Swift_ConnectionException("The ConnectionRotator plugin cannot be used with connections other than Swift_Connection_Rotator.");
     }
     if (!$this->called) {
         $this->used[] = $e->getSwift()->connection->getActive();
     }
     $this->count++;
     if ($this->count >= $this->getThreshold()) {
         $e->getSwift()->connection->nextConnection();
         if (!in_array($id = $e->getSwift()->connection->getActive(), $this->used)) {
             $e->getSwift()->connect();
             $this->used[] = $id;
         }
         $this->count = 0;
     }
     $this->called = true;
 }
Пример #2
0
 /**
  * Swift's SendEvent listener.
  * Invoked when Swift sends a message
  * @param Swift_Events_SendEvent The event information
  * @throws Swift_ConnectionException If the connection cannot be closed/re-opened
  */
 public function sendPerformed(Swift_Events_SendEvent $e)
 {
     $this->count++;
     if ($this->count >= $this->getThreshold()) {
         $e->getSwift()->disconnect();
         $this->wait($this->getWait());
         $e->getSwift()->connect();
         $this->count = 0;
     }
 }