From 082a25dd77a034923f1711d84f20b633fbbabc45 Mon Sep 17 00:00:00 2001 From: Astrologies Date: Thu, 9 Dec 2021 04:37:01 -0500 Subject: [PATCH] rccservicehelper dep --- .../Dependencies/Grid/RccServiceHelper.php | 122 ++++++++++-------- html/Game/PlaceLauncher.ashx | 9 +- 2 files changed, 73 insertions(+), 58 deletions(-) diff --git a/globals/Dependencies/Grid/RccServiceHelper.php b/globals/Dependencies/Grid/RccServiceHelper.php index bcf5a8f..4090951 100644 --- a/globals/Dependencies/Grid/RccServiceHelper.php +++ b/globals/Dependencies/Grid/RccServiceHelper.php @@ -7,6 +7,9 @@ */ namespace Alphaland\Grid { + + use stdClass; + class RccServiceHelper { private string $ServiceIp; @@ -16,13 +19,13 @@ namespace Alphaland\Grid { $this->ServiceIp = $ServiceIp; } - private function SoapCallService(string $name, array $arguments = []): mixed + private function SoapCallService(string $name, array $arguments = []) { $soapcl = new \SoapClient($GLOBALS['RCCwsdl'], ["location" => "http://" . $this->ServiceIp, "uri" => "http://roblox.com/", "exceptions" => false]); return $soapcl->{$name}($arguments); //thanks BrentDaMage didnt know u can do this } - private function VerifyLuaValue(mixed $value): string //mostly due to booleans, but maybe something will come up in the future + private function VerifyLuaValue($value) //mostly due to booleans, but maybe something will come up in the future { switch ($value) { case is_bool(json_encode($value)) || $value == 1: @@ -46,113 +49,120 @@ namespace Alphaland\Grid { private function ConstructLuaArguments(array $arguments = []): array //arguments for a script being executed { - if (!empty($arguments)) { - $luavalue = array("LuaValue" => array()); - foreach ($arguments as $argument) { - array_push($luavalue['LuaValue'], array( - "type" => $this->GetLuaType($argument), - "value" => $this->VerifyLuaValue($argument) - )); - } - return $luavalue; + $luavalue = array("LuaValue" => array()); + foreach ($arguments as $argument) { + array_push($luavalue['LuaValue'], array( + "type" => $this->GetLuaType($argument), + "value" => $this->VerifyLuaValue($argument) + )); } + return $luavalue; } - private function ConstructJobTemplate(string $servicename, string $jobid, int $expiration, int $category, int $cores, string $scriptname, string $script, array $arguments = []): mixed + public function ConstructGenericJob(string $jobid, int $expiration, int $category, int $cores, string $scriptname, string $script, array $arguments = []): array { - return $this->SoapCallService( - $servicename, - array( - "job" => array( - "id" => $jobid, - "expirationInSeconds" => $expiration, - "category" => $category, - "cores" => $cores - ), - "script" => array( - "name" => $scriptname, - "script" => $script, - "arguments" => $this->ConstructLuaArguments($arguments) - ) + return array( + "job" => array( + "id" => $jobid, + "expirationInSeconds" => $expiration, + "category" => $category, + "cores" => $cores + ), + "script" => array( + "name" => $scriptname, + "script" => $script, + "arguments" => $this->ConstructLuaArguments($arguments) ) ); } - public function GetVersion(): mixed + public function ConstructGenericScriptExecute(string $jobid, string $scriptname, string $script, array $arguments = []): array + { + return array( + "jobID" => $jobid, + "script" => array( + "name" => $scriptname, + "script" => $script, + "arguments" => $this->ConstructLuaArguments($arguments) + ) + ); + } + + public function GetVersion(): stdClass { return $this->SoapCallService("GetVersion"); } - public function HelloWorld(): mixed + public function HelloWorld(): stdClass { return $this->SoapCallService("HelloWorld"); } - public function CloseAllJobs(): mixed + public function CloseAllJobs(): stdClass { return $this->SoapCallService("CloseAllJobs"); } - public function CloseExpiredJobs(): mixed + public function CloseExpiredJobs(): stdClass { return $this->SoapCallService("CloseExpiredJobs"); } - public function GetAllJobsEx(): mixed + public function GetAllJobsEx(): stdClass { return $this->SoapCallService("GetAllJobsEx"); } - public function GetStatus(): mixed + public function GetStatus(): stdClass { return $this->SoapCallService("GetStatus"); } - public function DiagEx(string $type, string $jobid): mixed + public function DiagEx(string $type, string $jobid): stdClass { return $this->SoapCallService("DiagEx", array("type" => $type, "jobID" => $jobid)); } // this doesn't return anything + // austin: i know this doesnt return anything // https://pastebin.com/raw/pr5NDBwC - public function CloseJob(string $jobid): mixed + public function CloseJob(string $jobid): stdClass { return $this->SoapCallService("CloseJob", array("jobID" => $jobid)); } - public function GetExpiration(string $jobid): mixed + public function GetExpiration(string $jobid): stdClass { return $this->SoapCallService("GetExpiration", array("jobID" => $jobid)); } - public function ExecuteEx(string $jobid, string $scriptname, string $script, array $arguments = []): mixed - { - return $this->SoapCallService( - "ExecuteEx", - array( - "jobID" => $jobid, - "script" => array( - "name" => $scriptname, - "script" => $script, - "arguments" => $this->ConstructLuaArguments($arguments) - ) - ) - ); - } - - public function RenewLease(string $jobid, int $expiration): mixed + public function RenewLease(string $jobid, int $expiration): stdClass { return $this->SoapCallService("RenewLease", array("jobID" => $jobid, "expirationInSeconds" => $expiration)); } - - public function OpenJobEx(string $jobid, int $expiration, string $scriptname, string $script, array $arguments = []): mixed + + public function ExecuteEx(array $soapargs = []): stdClass { - return $this->ConstructJobTemplate("OpenJobEx", $jobid, $expiration, 1, 3, $scriptname, $script, $arguments); + return $this->SoapCallService( + "ExecuteEx", + $soapargs + ); } - public function BatchJobEx(string $jobid, int $expiration, string $scriptname, string $script, array $arguments = []): mixed + public function OpenJobEx(array $soapargs = []): stdClass { - return $this->ConstructJobTemplate("BatchJobEx", $jobid, $expiration, 1, 3, $scriptname, $script, $arguments); + return $this->SoapCallService( + "OpenJobEx", + $soapargs + ); + } + + public function BatchJobEx(array $soapargs = []): stdClass + { + return $this->SoapCallService( + "BatchJobEx", + $soapargs + ); } } } diff --git a/html/Game/PlaceLauncher.ashx b/html/Game/PlaceLauncher.ashx index bbaab10..a714ed2 100644 --- a/html/Game/PlaceLauncher.ashx +++ b/html/Game/PlaceLauncher.ashx @@ -5,6 +5,8 @@ This is used on the client (if the client has the session token set) to request TODO: Clean up */ +use Alphaland\Grid\RccServiceHelper; + $requesttype = $_GET['request']; $local = $_GET['local']; @@ -83,13 +85,16 @@ function StartServer($gid) //launch the server $script = file_get_contents($GLOBALS['gameserverscript']); - $gameSpawnResult = soapOpenJobEx($GLOBALS['gamesArbiter'], $jobuuid, 60, "Start Server ".$gid, $script, array( + + $gameSpawnResult = new RccServiceHelper($GLOBALS['gamesArbiter']); + $gameSpawnResult->OpenJobEx( + $gameSpawnResult->ConstructGenericJob($jobuuid, 60, 0, 0, "Start Server ".$gid, $script, array( $gid, //placeid $port, //gameserver port $GLOBALS['domain'], //domain $gameInfo->CreatorId, //place creatorid (bool)$gameInfo->isPersonalServer //ispersonalserver - ) + )) ); if (is_soap_fault($gameSpawnResult)) {