diff --git a/src/Socialbox/SocialClient.php b/src/Socialbox/SocialClient.php index 57870ec..c3a6a7e 100644 --- a/src/Socialbox/SocialClient.php +++ b/src/Socialbox/SocialClient.php @@ -613,6 +613,21 @@ )->getResponse()->getResult(); } + /** + * Authenticates the user by sending a remote procedure call request. + * Only applicable for server to server communication, this is the first method to call + * after connecting to the server. + * + * @return true Returns true if the authentication is successful. + * @throws RpcException Thrown if the RPC request fails. + */ + public function authenticate(): true + { + return (bool)$this->sendRequest( + new RpcRequest(StandardMethods::AUTHENTICATE->value, Utilities::randomCrc32()) + )->getResponse()->getResult(); + } + /** * Resolves a peer by its address or a PeerAddress instance through a remote procedure call. * diff --git a/src/Socialbox/Socialbox.php b/src/Socialbox/Socialbox.php index 7d52361..1fb3543 100644 --- a/src/Socialbox/Socialbox.php +++ b/src/Socialbox/Socialbox.php @@ -624,6 +624,7 @@ try { $client = new SocialClient(self::getServerAddress(), $domain); + $client->authenticate(); } catch (Exception $e) {