diff --git a/src/Socialbox/Classes/StandardMethods/CreateSession.php b/src/Socialbox/Classes/StandardMethods/CreateSession.php new file mode 100644 index 0000000..35fa556 --- /dev/null +++ b/src/Socialbox/Classes/StandardMethods/CreateSession.php @@ -0,0 +1,49 @@ +containsParameter('public_key')) + { + return $rpcRequest->produceError(StandardError::RPC_INVALID_ARGUMENTS, 'Missing parameter \'public_key\''); + } + + try + { + $uuid = SessionManager::createSession($rpcRequest->getParameter('public_key')); + } + catch(DatabaseOperationException $e) + { + return $rpcRequest->produceError(StandardError::INTERNAL_SERVER_ERROR, 'There was an error while trying to create a new session: ' . $e->getMessage()); + } + catch(InvalidArgumentException $e) + { + return $rpcRequest->produceError(StandardError::RPC_INVALID_ARGUMENTS, $e->getMessage()); + } + + return $rpcRequest->produceResponse([ + 'uuid' => $uuid + ]); + } +} \ No newline at end of file