コード例 #1
0
ファイル: L5.php プロジェクト: renwuxun/core
 /**
  * @param int $sid
  * @return array [ip, port]
  */
 public function route($sid)
 {
     $msg = Core_Helper_Net_Http::buildRequest('/get/' . $sid, '', 'GET');
     $this->tcp->send($msg);
     $retheader = Core_Helper_Net_Http::readHeader($this->tcp);
     $errno = 0;
     $errstr = '';
     $body = Core_Helper_Net_Http::readBody($this->tcp, $retheader, $errno, $errstr);
     return explode(':', trim($body));
 }
コード例 #2
0
ファイル: UUID.php プロジェクト: renwuxun/core
 /**
  * @return int
  */
 public function get()
 {
     if ($this->serverDown) {
         list($usec, $sec) = explode(" ", microtime());
         $time_ms = $sec * 1000 + $usec / 1000;
         $count = rand(0, 16383);
         $gpid = 0;
         // php生产的uuid特有的标记
         return $time_ms << 22 | $count << 9 | $gpid;
     }
     $msg = Core_Helper_Net_Http::buildRequest('/', '', 'GET');
     $this->tcp->send($msg);
     $header = Core_Helper_Net_Http::readHeader($this->tcp);
     $body = Core_Helper_Net_Http::readBody($this->tcp, $header, $this->errno, $this->errstr);
     return (int) trim($body);
 }