Refactor peer synchronization and resolution logic.
This commit is contained in:
parent
f9a268058f
commit
ab03439e04
2 changed files with 29 additions and 14 deletions
|
@ -66,21 +66,11 @@
|
|||
// Otherwise, resolve the peer from the remote server
|
||||
try
|
||||
{
|
||||
$client = Socialbox::getExternalSession($peerAddress->getDomain());
|
||||
return $rpcRequest->produceResponse(Socialbox::resolveExternalPeer($peerAddress));
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
throw new StandardException(sprintf('There was an error while trying to connect to %s: %s', $peerAddress->getDomain(), $e->getMessage()), StandardError::RESOLUTION_FAILED, $e);
|
||||
}
|
||||
|
||||
// Return the result/error of the resolution
|
||||
try
|
||||
{
|
||||
return $rpcRequest->produceResponse($client->resolvePeer($peerAddress));
|
||||
}
|
||||
catch(RpcException $e)
|
||||
{
|
||||
throw new StandardException($e->getMessage(), StandardError::tryFrom($e->getCode()) ?? StandardError::UNKNOWN, $e);
|
||||
throw new StandardException(sprintf('There was an error while trying to resolve the peer %s: %s', $peerAddress, $e->getMessage()), StandardError::RESOLUTION_FAILED, $e);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue