From 2a1cf0bae3391b96aa21f07c0e0c7b8f8cc6164a Mon Sep 17 00:00:00 2001 From: netkas Date: Fri, 13 Sep 2024 13:47:45 -0400 Subject: [PATCH] Add ClientRequest class for handling client RPC requests --- src/Socialbox/Objects/ClientRequest.php | 109 ++++++++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 src/Socialbox/Objects/ClientRequest.php diff --git a/src/Socialbox/Objects/ClientRequest.php b/src/Socialbox/Objects/ClientRequest.php new file mode 100644 index 0000000..6e6bf7c --- /dev/null +++ b/src/Socialbox/Objects/ClientRequest.php @@ -0,0 +1,109 @@ +headers = $headers; + $this->requests = $requests; + $this->requestHash = $requestHash; + } + + /** + * @return array + */ + public function getHeaders(): array + { + return $this->headers; + } + + /** + * @return RpcRequest[] + */ + public function getRequests(): array + { + return $this->requests; + } + + public function getHash(): string + { + return $this->requestHash; + } + + public function getClientName(): string + { + return $this->headers[StandardHeaders::CLIENT_NAME->value]; + } + + public function getClientVersion(): string + { + return $this->headers[StandardHeaders::CLIENT_VERSION->value]; + } + + public function getSessionUuid(): ?string + { + if(!isset($this->headers[StandardHeaders::SESSION_UUID->value])) + { + return null; + } + + return $this->headers[StandardHeaders::SESSION_UUID->value]; + } + + public function getFromPeer(): ?PeerAddress + { + if(!isset($this->headers[StandardHeaders::FROM_PEER->value])) + { + return null; + } + + return PeerAddress::fromAddress($this->headers[StandardHeaders::FROM_PEER->value]); + } + + public function getSignature(): ?string + { + if(!isset($this->headers[StandardHeaders::SIGNATURE->value])) + { + return null; + } + + return $this->headers[StandardHeaders::SIGNATURE->value]; + } + + public function verifySignature(): bool + { + $signature = $this->getSignature(); + + if($signature == null) + { + return false; + } + + + } +} \ No newline at end of file