-
Notifications
You must be signed in to change notification settings - Fork 256
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
35 changed files
with
5,465 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
require_once dirname(dirname(__DIR__)) . '/hprose/lib/Client.php'; | ||
class hprose | ||
{ | ||
public static $instance; | ||
public function __construct() { | ||
} | ||
public static function getdata() | ||
{ | ||
$hprose_config = Yaf_Registry::get("config")->hprose->toArray(); | ||
$client = new Client("tcp://" . $hprose_config['ServerIp'] . ":" . $hprose_config['port'],false); | ||
return $client->zys("zys"); | ||
} | ||
public static function getInstance() { | ||
if (!(self::$instance instanceof hprose)) { | ||
self::$instance = new hprose; | ||
} | ||
return self::$instance; | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,156 @@ | ||
<?php | ||
/**********************************************************\ | ||
| | | ||
| hprose | | ||
| | | ||
| Official WebSite: http://www.hprose.com/ | | ||
| http://www.hprose.org/ | | ||
| | | ||
\**********************************************************/ | ||
|
||
/**********************************************************\ | ||
* * | ||
* Hprose/BytesIO.php * | ||
* * | ||
* hprose BytesIO class for php 5.3+ * | ||
* * | ||
* LastModified: Jul 11, 2015 * | ||
* Author: Ma Bingyao <[email protected]> * | ||
* * | ||
\**********************************************************/ | ||
class BytesIO { | ||
protected $buffer; | ||
protected $length; | ||
protected $pos = 0; | ||
protected $mark = -1; | ||
public function __construct($string = '') { | ||
$this->buffer = $string; | ||
$this->length = strlen($string); | ||
} | ||
public function close() { | ||
$this->buffer = ''; | ||
$this->pos = 0; | ||
$this->mark = -1; | ||
$this->length = 0; | ||
} | ||
public function length() { | ||
return $this->length; | ||
} | ||
public function getc() { | ||
if ($this->pos < $this->length) { | ||
return $this->buffer[$this->pos++]; | ||
} | ||
return ''; | ||
} | ||
public function read($n) { | ||
$s = substr($this->buffer, $this->pos, $n); | ||
$this->skip($n); | ||
return $s; | ||
} | ||
public function readfull() { | ||
$s = substr($this->buffer, $this->pos); | ||
$this->pos = $this->length; | ||
return $s; | ||
} | ||
public function readuntil($tag) { | ||
$pos = strpos($this->buffer, $tag, $this->pos); | ||
if ($pos !== false) { | ||
$s = substr($this->buffer, $this->pos, $pos - $this->pos); | ||
$this->pos = $pos + strlen($tag); | ||
} | ||
else { | ||
$s = substr($this->buffer, $this->pos); | ||
$this->pos = $this->length; | ||
} | ||
return $s; | ||
} | ||
public function readString($n) { | ||
$pos = $this->pos; | ||
$buffer = $this->buffer; | ||
for ($i = 0; $i < $n; ++$i) { | ||
switch (ord($buffer[$pos]) >> 4) { | ||
case 0: | ||
case 1: | ||
case 2: | ||
case 3: | ||
case 4: | ||
case 5: | ||
case 6: | ||
case 7: { | ||
// 0xxx xxxx | ||
++$pos; | ||
break; | ||
} | ||
case 12: | ||
case 13: { | ||
// 110x xxxx 10xx xxxx | ||
$pos += 2; | ||
break; | ||
} | ||
case 14: { | ||
// 1110 xxxx 10xx xxxx 10xx xxxx | ||
$pos += 3; | ||
break; | ||
} | ||
case 15: { | ||
// 1111 0xxx 10xx xxxx 10xx xxxx 10xx xxxx | ||
$pos += 4; | ||
++$i; | ||
if ($i >= $n) { | ||
throw new Exception('bad utf-8 encoding'); | ||
} | ||
break; | ||
} | ||
default: { | ||
throw new Exception('bad utf-8 encoding'); | ||
} | ||
} | ||
} | ||
return $this->read($pos - $this->pos); | ||
} | ||
public function mark() { | ||
$this->mark = $this->pos; | ||
} | ||
public function unmark() { | ||
$this->mark = -1; | ||
} | ||
public function reset() { | ||
if ($this->mark != -1) { | ||
$this->pos = $this->mark; | ||
} | ||
} | ||
public function skip($n) { | ||
$this->pos += $n; | ||
} | ||
public function eof() { | ||
return ($this->pos >= $this->length); | ||
} | ||
public function write($str, $n = -1) { | ||
if ($n == -1) { | ||
$this->buffer .= $str; | ||
$n = strlen($str); | ||
} | ||
else { | ||
$this->buffer .= substr($str, 0, $n); | ||
} | ||
$this->length += $n; | ||
} | ||
public function load($filename) { | ||
$str = file_get_contents($filename); | ||
if ($str === false) return false; | ||
$this->buffer = $str; | ||
$this->pos = 0; | ||
$this->mark = -1; | ||
$this->length = strlen($str); | ||
return true; | ||
} | ||
public function save($filename) { | ||
return file_put_contents($filename, $this->buffer); | ||
} | ||
public function toString() { | ||
return $this->buffer; | ||
} | ||
public function __toString() { | ||
return $this->buffer; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
<?php | ||
/**********************************************************\ | ||
| | | ||
| hprose | | ||
| | | ||
| Official WebSite: http://www.hprose.com/ | | ||
| http://www.hprose.org/ | | ||
| | | ||
\**********************************************************/ | ||
|
||
/**********************************************************\ | ||
* * | ||
* Hprose/Socket/Client.php * | ||
* * | ||
* hprose socket client class for php 5.3+ * | ||
* * | ||
* LastModified: Aug 6, 2016 * | ||
* Author: Ma Bingyao <[email protected]> * | ||
* * | ||
\**********************************************************/ | ||
require_once __DIR__ . '/Socket_Client.php'; | ||
require_once __DIR__ . '/HalfDuplexTransporter.php'; | ||
require_once __DIR__ . '/FullDuplexTransporter.php'; | ||
class Client extends Socket_Client { | ||
private $hdtrans; | ||
private $fdtrans; | ||
public $fullDuplex = false; | ||
public $readBuffer = 8192; | ||
public $writeBuffer = 8192; | ||
public $maxPoolSize = 10; | ||
public $noDelay = true; | ||
public $keepAlive = true; | ||
public $options = null; | ||
public function __construct($uris = null, $async = true) { | ||
parent::__construct($uris, $async); | ||
$this->hdtrans = new HalfDuplexTransporter($this, $async); | ||
$this->fdtrans = new FullDuplexTransporter($this, $async); | ||
} | ||
public function __destruct() { | ||
try { | ||
$this->loop(); | ||
} | ||
catch (\Exception $e) { | ||
} | ||
} | ||
public function isFullDuplex() { | ||
return $this->fullDuplex; | ||
} | ||
public function setFullDuplex($fullDuplex) { | ||
$this->fullDuplex = $fullDuplex; | ||
} | ||
public function getReadBuffer() { | ||
return $this->readBuffer; | ||
} | ||
public function setReadBuffer($size) { | ||
$this->readBuffer = $size; | ||
} | ||
public function getWriteBuffer() { | ||
return $this->writeBuffer; | ||
} | ||
public function setWriteBuffer($size) { | ||
$this->writeBuffer = $size; | ||
} | ||
public function getMaxPoolSize() { | ||
return $this->maxPoolSize; | ||
} | ||
public function setMaxPoolSize($maxPoolSize) { | ||
if ($maxPoolSize < 1) throw new Exception("maxPoolSize must be great than 0"); | ||
$this->maxPoolSize = $maxPoolSize; | ||
} | ||
public function setNoDelay($value) { | ||
$this->noDelay = $value; | ||
} | ||
public function isNoDelay() { | ||
return $this->noDelay; | ||
} | ||
public function setKeepAlive($value) { | ||
$this->keepAlive = $value; | ||
} | ||
public function isKeepAlive() { | ||
return $this->keepAlive; | ||
} | ||
protected function sendAndReceive($request, stdClass $context) { | ||
if ($this->fullDuplex) { | ||
return $this->fdtrans->sendAndReceive($request, $context); | ||
} | ||
return $this->hdtrans->sendAndReceive($request, $context); | ||
} | ||
public function getOptions() { | ||
return $this->options; | ||
} | ||
public function setOptions(array $options) { | ||
$this->options = $options; | ||
} | ||
public function set($key, $value) { | ||
$this->options[$key] = $value; | ||
return $this; | ||
} | ||
public function loop() { | ||
if ($this->fullDuplex) { | ||
$this->fdtrans->loop(); | ||
} | ||
else { | ||
$this->hdtrans->loop(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
/**********************************************************\ | ||
| | | ||
| hprose | | ||
| | | ||
| Official WebSite: http://www.hprose.com/ | | ||
| http://www.hprose.org/ | | ||
| | | ||
\**********************************************************/ | ||
|
||
/**********************************************************\ | ||
* * | ||
* Hprose/FakeReaderRefer.php * | ||
* * | ||
* hprose FakeReaderRefer class for php 5.3+ * | ||
* * | ||
* LastModified: Jul 11, 2016 * | ||
* Author: Ma Bingyao <[email protected]> * | ||
* * | ||
\**********************************************************/ | ||
require_once __DIR__ . '/ReaderRefer.php'; | ||
class FakeReaderRefer implements ReaderRefer { | ||
public function set($val) {} | ||
public function read($index) { | ||
throw new Exception("Unexpected serialize tag '" . | ||
Tags::TagRef . | ||
"' in stream"); | ||
} | ||
public function reset() {} | ||
} |
Oops, something went wrong.