コード例 #1
0
ファイル: Sender.php プロジェクト: RodMing/php-gcm
 /**
  * Updates the status of the messages sent to devices and the list of devices
  * that should be retried.
  *
  * @param array unsentRegIds list of devices that are still pending an update.
  * @param array allResults map of status that will be updated.
  * @param MulticastResult multicastResult result of the last multicast sent.
  *
  * @return array updated version of devices that should be retried.
  */
 private function updateStatus($unsentRegIds, &$allResults, MulticastResult $multicastResult)
 {
     $results = $multicastResult->getResults();
     if (count($results) != count($unsentRegIds)) {
         // should never happen, unless there is a flaw in the algorithm
         throw new \RuntimeException('Internal error: sizes do not match. currentResults: ' . $results . '; unsentRegIds: ' + $unsentRegIds);
     }
     $newUnsentRegIds = array();
     for ($i = 0; $i < count($unsentRegIds); $i++) {
         $regId = $unsentRegIds[$i];
         $result = $results[$i];
         $allResults[$regId] = $result;
         $error = $result->getErrorCode();
         if (!is_null($error) && $error == Constants::$ERROR_UNAVAILABLE) {
             $newUnsentRegIds[] = $regId;
         }
     }
     return $newUnsentRegIds;
 }
コード例 #2
0
 public function testGetRetryMulticastIds()
 {
     $result = new MulticastResult(1, 2, 1, 'multicast-id', array(1));
     $this->assertEquals(array(1), $result->getRetryMulticastIds());
 }