| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- <?php
- /**
- * Created by PhpStorm.
- * User: liyunlong
- * Date: 2018-12-24
- * Time: 11:54
- */
- namespace common\libs\swoole;
- class RPCResult
- {
- public $code = self::ERR_NO_READY;
- public $msg;
- public $data = null;
- public $send; //要发送的数据
- public $type;
- public $index;
- /**
- * 请求串号
- */
- public $requestId;
- /**
- * 回调函数
- * @var mixed
- */
- public $callback;
- /**
- * @var
- */
- public $socket = null;
- /**
- * SOA服务器的IP地址
- * @var string
- */
- public $server_host;
- /**
- * SOA服务器的端口
- * @var int
- */
- public $server_port;
- /**
- * @var RPCResult
- */
- protected $soa_client;
- const ERR_NO_READY = 8001; //未就绪
- const ERR_CONNECT = 8002; //连接服务器失败
- const ERR_TIMEOUT = 8003; //服务器端超时
- const ERR_SEND = 8004; //发送失败
- const ERR_SERVER = 8005; //server返回了错误码
- const ERR_UNPACK = 8006; //解包失败了
- const ERR_HEADER = 8007; //错误的协议头
- const ERR_TOOBIG = 8008; //超过最大允许的长度
- const ERR_CLOSED = 8009; //连接被关闭
- const ERR_RECV = 8010; //等待接收数据
- function __construct($soa_client)
- {
- $this->soa_client = $soa_client;
- }
- function getResult($timeout = 0.5)
- {
- if ($this->code == self::ERR_RECV)
- {
- $this->soa_client->wait($timeout);
- }
- return $this->data;
- }
- }
|