Ejemplo n.º 1
0
 public function process($data)
 {
     $this->daemon->tick();
     //grab session id and number
     $data['message'] = array_merge(['count' => 1, 'mode' => 'photo', 'delay' => 0], $data['message']);
     $session = $data['message']['session'];
     $number = $data['message']['number'];
     $mode = $data['message']['mode'];
     $count = $data['message']['count'];
     $delay = $data['message']['delay'];
     if (!$session) {
         error_log('no session');
         return $this->daemon->run;
     }
     error_log('message data: ' . json_encode($data['message']));
     if ($delay) {
         sleep($delay);
     }
     //take photo
     switch ($mode) {
         case 'photo':
         default:
             error_log('taking photo');
             $this->gopro->shutter();
             sleep(2);
             break;
     }
     $last = $this->gopro->getLastFile(GoPro::FILTER_PHOTO);
     error_log('got last file: ' . $last);
     error_log('adding photo to session: ' . $last);
     $this->darkroom->addPhoto($session, $last, $number);
     $this->daemon->tick();
     return $this->daemon->run;
 }