Enhance session handling and introduce session flags
This commit is contained in:
parent
6c8cbfddec
commit
790262db08
6 changed files with 251 additions and 81 deletions
40
src/Socialbox/Classes/StandardMethods/GetSession.php
Normal file
40
src/Socialbox/Classes/StandardMethods/GetSession.php
Normal file
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
|
||||
namespace Socialbox\Classes\StandardMethods;
|
||||
|
||||
use Socialbox\Abstracts\Method;
|
||||
use Socialbox\Enums\StandardError;
|
||||
use Socialbox\Exceptions\DatabaseOperationException;
|
||||
use Socialbox\Exceptions\StandardException;
|
||||
use Socialbox\Interfaces\SerializableInterface;
|
||||
use Socialbox\Managers\RegisteredPeerManager;
|
||||
use Socialbox\Managers\SessionManager;
|
||||
use Socialbox\Objects\ClientRequest;
|
||||
use Socialbox\Objects\RpcRequest;
|
||||
|
||||
class GetSession extends Method
|
||||
{
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function execute(ClientRequest $request, RpcRequest $rpcRequest): ?SerializableInterface
|
||||
{
|
||||
if($request->getSessionUuid() === null)
|
||||
{
|
||||
return $rpcRequest->produceError(StandardError::SESSION_REQUIRED);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
// Get the session
|
||||
$session = SessionManager::getSession($request->getSessionUuid());
|
||||
}
|
||||
catch(DatabaseOperationException $e)
|
||||
{
|
||||
throw new StandardException("There was an unexpected error while trying to retrieve the session", StandardError::INTERNAL_SERVER_ERROR, $e);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue