[Server] Fix: ensure JSON-RPC error responses include message IDs (#77)
* fix: ensure JSON-RPC error responses include message IDs * fix: replace method_exists with instanceof for message ID extraction
This commit is contained in:
parent
325b4aaf9c
commit
32b8b2ea61
1 changed files with 38 additions and 35 deletions
|
|
@ -44,19 +44,12 @@ final class Server
|
|||
]);
|
||||
|
||||
$transport->onMessage(function (string $message, ?Uuid $sessionId) use ($transport) {
|
||||
try {
|
||||
foreach ($this->jsonRpcHandler->process($message, $sessionId) as [$response, $context]) {
|
||||
if (null === $response) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$transport->send($response, $context);
|
||||
foreach ($this->jsonRpcHandler->process($message, $sessionId) as [$response, $context]) {
|
||||
if (null === $response) {
|
||||
continue;
|
||||
}
|
||||
} catch (\JsonException $e) {
|
||||
$this->logger->error('Failed to encode response to JSON.', [
|
||||
'message' => $message,
|
||||
'exception' => $e,
|
||||
]);
|
||||
|
||||
$transport->send($response, $context);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue