Exemplo n.º 1
0
 /**
  * Idle processing for io manager's execution loop.
  *
  * @return void
  */
 public function idle()
 {
     // Send a ping if necessary
     if (empty($this->lastPing) || time() - $this->lastPing > $this->plugin->pinginterval) {
         $this->sendPing();
     }
     if ($this->connected) {
         // Send a waiting message if appropriate
         if ($this->messageWaiting && time() - $this->lastMessage > 1) {
             $wm = Irc_waiting_message::top();
             if ($wm === NULL) {
                 $this->messageWaiting = false;
                 return;
             }
             $data = unserialize($wm->data);
             $wm->incAttempts();
             if ($this->send_raw_message($data)) {
                 $wm->delete();
             } else {
                 if ($wm->attempts <= common_config('queue', 'max_retries')) {
                     // Try again next idle
                     $wm->releaseClaim();
                 } else {
                     // Exceeded the maximum number of retries
                     $wm->delete();
                 }
             }
         }
     }
 }