改名
This commit is contained in:
+3
-2
@@ -7,6 +7,7 @@ namespace Rpc;
|
|||||||
use Exception;
|
use Exception;
|
||||||
use Snowflake\Abstracts\Component;
|
use Snowflake\Abstracts\Component;
|
||||||
use Snowflake\Abstracts\Config;
|
use Snowflake\Abstracts\Config;
|
||||||
|
use Snowflake\Core\Json;
|
||||||
use Snowflake\Exception\ConfigException;
|
use Snowflake\Exception\ConfigException;
|
||||||
use Swoole\Coroutine\Client as CClient;
|
use Swoole\Coroutine\Client as CClient;
|
||||||
|
|
||||||
@@ -47,12 +48,12 @@ class Client extends Component
|
|||||||
return $this->addError($this->client->errMsg . '(' . $this->client->errCode . ')');
|
return $this->addError($this->client->errMsg . '(' . $this->client->errCode . ')');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$isSend = $this->client->send(serialize(['cmd' => $cmd, 'body' => $param]));
|
$isSend = $this->client->send(Json::encode(['cmd' => $cmd, 'body' => $param]));
|
||||||
if ($isSend === false) {
|
if ($isSend === false) {
|
||||||
return $this->addError($this->client->errMsg . '(' . $this->client->errCode . ')');
|
return $this->addError($this->client->errMsg . '(' . $this->client->errCode . ')');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_bool($unpack = unserialize($this->client->recv()))) {
|
if (is_bool($unpack = Json::decode($this->client->recv()))) {
|
||||||
return $this->addError('Service return data format error(500)');
|
return $this->addError('Service return data format error(500)');
|
||||||
}
|
}
|
||||||
return $unpack;
|
return $unpack;
|
||||||
|
|||||||
+2
-2
@@ -73,10 +73,10 @@ class Service extends Component
|
|||||||
if (($node = router()->find_path($this->replace($request, $service))) === null) {
|
if (($node = router()->find_path($this->replace($request, $service))) === null) {
|
||||||
throw new Exception('Cmd not find.');
|
throw new Exception('Cmd not find.');
|
||||||
}
|
}
|
||||||
return serialize($node->dispatch());
|
return Json::encode($node->dispatch());
|
||||||
} catch (\Throwable $exception) {
|
} catch (\Throwable $exception) {
|
||||||
$this->addError($exception);
|
$this->addError($exception);
|
||||||
return serialize(['state' => 'fail', 'message' => $exception->getMessage()]);
|
return Json::encode(['state' => 'fail', 'message' => $exception->getMessage()]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user