rccservicehelper dep
This commit is contained in:
parent
22d55f6c4d
commit
082a25dd77
|
|
@ -7,6 +7,9 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Alphaland\Grid {
|
namespace Alphaland\Grid {
|
||||||
|
|
||||||
|
use stdClass;
|
||||||
|
|
||||||
class RccServiceHelper
|
class RccServiceHelper
|
||||||
{
|
{
|
||||||
private string $ServiceIp;
|
private string $ServiceIp;
|
||||||
|
|
@ -16,13 +19,13 @@ namespace Alphaland\Grid {
|
||||||
$this->ServiceIp = $ServiceIp;
|
$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]);
|
$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
|
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) {
|
switch ($value) {
|
||||||
case is_bool(json_encode($value)) || $value == 1:
|
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
|
private function ConstructLuaArguments(array $arguments = []): array //arguments for a script being executed
|
||||||
{
|
{
|
||||||
if (!empty($arguments)) {
|
$luavalue = array("LuaValue" => array());
|
||||||
$luavalue = array("LuaValue" => array());
|
foreach ($arguments as $argument) {
|
||||||
foreach ($arguments as $argument) {
|
array_push($luavalue['LuaValue'], array(
|
||||||
array_push($luavalue['LuaValue'], array(
|
"type" => $this->GetLuaType($argument),
|
||||||
"type" => $this->GetLuaType($argument),
|
"value" => $this->VerifyLuaValue($argument)
|
||||||
"value" => $this->VerifyLuaValue($argument)
|
));
|
||||||
));
|
|
||||||
}
|
|
||||||
return $luavalue;
|
|
||||||
}
|
}
|
||||||
|
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(
|
return array(
|
||||||
$servicename,
|
"job" => array(
|
||||||
array(
|
"id" => $jobid,
|
||||||
"job" => array(
|
"expirationInSeconds" => $expiration,
|
||||||
"id" => $jobid,
|
"category" => $category,
|
||||||
"expirationInSeconds" => $expiration,
|
"cores" => $cores
|
||||||
"category" => $category,
|
),
|
||||||
"cores" => $cores
|
"script" => array(
|
||||||
),
|
"name" => $scriptname,
|
||||||
"script" => array(
|
"script" => $script,
|
||||||
"name" => $scriptname,
|
"arguments" => $this->ConstructLuaArguments($arguments)
|
||||||
"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");
|
return $this->SoapCallService("GetVersion");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function HelloWorld(): mixed
|
public function HelloWorld(): stdClass
|
||||||
{
|
{
|
||||||
return $this->SoapCallService("HelloWorld");
|
return $this->SoapCallService("HelloWorld");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function CloseAllJobs(): mixed
|
public function CloseAllJobs(): stdClass
|
||||||
{
|
{
|
||||||
return $this->SoapCallService("CloseAllJobs");
|
return $this->SoapCallService("CloseAllJobs");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function CloseExpiredJobs(): mixed
|
public function CloseExpiredJobs(): stdClass
|
||||||
{
|
{
|
||||||
return $this->SoapCallService("CloseExpiredJobs");
|
return $this->SoapCallService("CloseExpiredJobs");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function GetAllJobsEx(): mixed
|
public function GetAllJobsEx(): stdClass
|
||||||
{
|
{
|
||||||
return $this->SoapCallService("GetAllJobsEx");
|
return $this->SoapCallService("GetAllJobsEx");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function GetStatus(): mixed
|
public function GetStatus(): stdClass
|
||||||
{
|
{
|
||||||
return $this->SoapCallService("GetStatus");
|
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));
|
return $this->SoapCallService("DiagEx", array("type" => $type, "jobID" => $jobid));
|
||||||
}
|
}
|
||||||
|
|
||||||
// this doesn't return anything
|
// this doesn't return anything
|
||||||
|
// austin: i know this doesnt return anything
|
||||||
// https://pastebin.com/raw/pr5NDBwC
|
// https://pastebin.com/raw/pr5NDBwC
|
||||||
public function CloseJob(string $jobid): mixed
|
public function CloseJob(string $jobid): stdClass
|
||||||
{
|
{
|
||||||
return $this->SoapCallService("CloseJob", array("jobID" => $jobid));
|
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));
|
return $this->SoapCallService("GetExpiration", array("jobID" => $jobid));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function ExecuteEx(string $jobid, string $scriptname, string $script, array $arguments = []): mixed
|
public function RenewLease(string $jobid, int $expiration): stdClass
|
||||||
{
|
|
||||||
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
|
|
||||||
{
|
{
|
||||||
return $this->SoapCallService("RenewLease", array("jobID" => $jobid, "expirationInSeconds" => $expiration));
|
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
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,8 @@ This is used on the client (if the client has the session token set) to request
|
||||||
TODO: Clean up
|
TODO: Clean up
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use Alphaland\Grid\RccServiceHelper;
|
||||||
|
|
||||||
$requesttype = $_GET['request'];
|
$requesttype = $_GET['request'];
|
||||||
|
|
||||||
$local = $_GET['local'];
|
$local = $_GET['local'];
|
||||||
|
|
@ -83,13 +85,16 @@ function StartServer($gid)
|
||||||
|
|
||||||
//launch the server
|
//launch the server
|
||||||
$script = file_get_contents($GLOBALS['gameserverscript']);
|
$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
|
$gid, //placeid
|
||||||
$port, //gameserver port
|
$port, //gameserver port
|
||||||
$GLOBALS['domain'], //domain
|
$GLOBALS['domain'], //domain
|
||||||
$gameInfo->CreatorId, //place creatorid
|
$gameInfo->CreatorId, //place creatorid
|
||||||
(bool)$gameInfo->isPersonalServer //ispersonalserver
|
(bool)$gameInfo->isPersonalServer //ispersonalserver
|
||||||
)
|
))
|
||||||
);
|
);
|
||||||
|
|
||||||
if (is_soap_fault($gameSpawnResult)) {
|
if (is_soap_fault($gameSpawnResult)) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue