public function poll()
 {
     $curl = $this->getCurl();
     curl_setopt($curl, CURLOPT_HTTPGET, true);
     curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
     $headers = array('Content-Type: x-application/jamp-pull');
     curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
     $data = curl_exec($curl);
     log('poll response: ' . $data);
     if ($data === false) {
         throw new Exception('error polling: ' . curl_error($curl));
     }
     $list = json_decode($data);
     if ($list === null) {
         throw new \Exception($data);
     }
     $responses = array();
     foreach ($list as $array) {
         $msg = Jamp::unserializeArray($array);
         $responses[] = $msg;
     }
     return $responses;
 }
예제 #2
0
 public static function unserialize($json)
 {
     $array = \json_decode($json);
     $msg = Jamp::unserializeArray($array);
     return $msg;
 }