Beispiel #1
0
 public static function unserialize($json)
 {
     $array = \json_decode($json);
     $msg = Jamp::unserializeArray($array);
     return $msg;
 }
 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;
 }
Beispiel #3
0
<?php

namespace Baratine;

//$file = fopen('http://192.168.1.147:8085/s/pod/map/5?m=getAll');
var_dump(file_get_contents('http://192.168.1.147:8085/s/pod/map/5?m=getAll'));
require_once 'JampClient.php';
$msg = Jamp::unserialize('["query",{},"me",11,"/foo","getUserCount"]');
echo $msg->serialize();
echo "\n";
$msg = Jamp::unserialize('["reply",{},"me",0,123]');
echo $msg->serialize();
echo "\n";
$msg = Jamp::unserialize('["error",{},"me",4,"UNKNOWN","\'/foo2\' is an unknown service","io.baratine.core.ServiceNotFoundException"]');
echo $msg->serialize();
echo "\n";
$msg = Jamp::unserialize('["send",{},"/foo","getUserCount", 1, 2]');
echo $msg->serialize();
echo "\n";
echo "\n";
$jampClient = JampClient::create('http://192.168.1.147:8085/s/pod');
$jampClient->query('/map/5', 'getAll', null, function ($value) {
    echo "hello world\n";
    var_dump($value);
});
//var_dump($jampClient);