改名
This commit is contained in:
+5
-7
@@ -36,22 +36,20 @@ class Client extends Component
|
|||||||
public function dispatch(string $cmd, array $param): mixed
|
public function dispatch(string $cmd, array $param): mixed
|
||||||
{
|
{
|
||||||
if (empty($this->config)) {
|
if (empty($this->config)) {
|
||||||
return null;
|
return $this->addError('Related service not found(404)');
|
||||||
}
|
}
|
||||||
if (!($this->client instanceof CClient)) {
|
if (!($this->client instanceof CClient)) {
|
||||||
$this->client = $this->getClient();
|
$this->client = $this->getClient();
|
||||||
}
|
}
|
||||||
if (!$this->client->isConnected()) {
|
if (!$this->client->isConnected()) {
|
||||||
if (!$this->client->connect(
|
$settings = [$this->config['host'], $this->config['port'], $this->config['timeout'] ?? 1];
|
||||||
$this->config['host'], $this->config['port'],
|
if (!$this->client->connect(...$settings)) {
|
||||||
$this->config['timeout'] ?? 1
|
return $this->addError($this->client->errMsg . '(' . $this->client->errCode . ')');
|
||||||
)) {
|
|
||||||
return $this->client->errCode . ':' . $this->client->errMsg;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$isSend = $this->client->send(serialize(['cmd' => $cmd, 'body' => $param]));
|
$isSend = $this->client->send(serialize(['cmd' => $cmd, 'body' => $param]));
|
||||||
if ($isSend === false) {
|
if ($isSend === false) {
|
||||||
return $this->client->errCode . ':' . $this->client->errMsg;
|
return $this->addError($this->client->errMsg . '(' . $this->client->errCode . ')');
|
||||||
}
|
}
|
||||||
return unserialize($this->client->recv());
|
return unserialize($this->client->recv());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user