Пример #1
0
 /**
  * Get invalid devices
  *
  * @return array|Device[]
  *
  * @throws Exception\ConnectionUndefinedException
  */
 public function getInvalidDevices()
 {
     if (!$this->connection) {
         throw new Exception\ConnectionUndefinedException();
     }
     if (!$this->connection->is()) {
         if ($this->logger) {
             $this->logger->debug('Create feedback connection...');
         }
         $this->connection->create();
     }
     $data = $this->connection->read(-1);
     $this->connection->close();
     $feedback = array();
     if ($data) {
         foreach (str_split($data, 38) as $deviceData) {
             $feedback[] = new Device($deviceData);
         }
     }
     if ($this->logger) {
         $this->logger->info(sprintf('%d device tokens received from feedback service.', count($feedback)));
     }
     return $feedback;
 }
Пример #2
0
 /**
  * Write payload data to connection
  *
  * @param string $payload
  *
  * @return bool
  */
 private function writePayload($payload)
 {
     return strlen($payload) === $this->connection->write($payload, strlen($payload));
 }