This commit is contained in:
2021-10-28 16:17:25 +08:00
parent 642e16a07c
commit cd17f2b63b
+3 -15
View File
@@ -97,11 +97,7 @@ class RpcJsonp extends Component implements OnConnectInterface, OnReceiveInterfa
private function batchDispatch(Server $server, int $fd, array $data): void
{
if (isset($data['jsonrpc'])) {
$dispatch = $this->dispatch($data);
if (!isset($data['id'])) {
return;
}
$result = json_encode($dispatch, JSON_UNESCAPED_UNICODE);
$result = json_encode($this->dispatch($data), JSON_UNESCAPED_UNICODE);
} else {
$channel = new Channel($total = count($data));
foreach ($data as $datum) {
@@ -109,11 +105,7 @@ class RpcJsonp extends Component implements OnConnectInterface, OnReceiveInterfa
}
$result = [];
for ($i = 0; $i < $total; $i++) {
$params = $channel->pop();
if (empty($params)) {
continue;
}
$result[] = $params;
$result[] = $channel->pop();
}
}
$server->send($fd, json_encode($result, JSON_UNESCAPED_UNICODE));
@@ -132,11 +124,7 @@ class RpcJsonp extends Component implements OnConnectInterface, OnReceiveInterfa
} else if (!isset($datum['method'])) {
$channel->push($this->failure(-32700, 'Parse error语法解析错误'));
} else {
$dispatch = $this->dispatch($datum);
if (!isset($dispatch['id'])) {
$dispatch = null;
}
$channel->push($dispatch);
$channel->push($this->dispatch($datum));
}
});
}