wip: 2024-03-19T16:51:47+0100 (1710863507)

This commit is contained in:
Victor Westerlund 2024-03-19 16:52:19 +01:00
parent 1d55090a31
commit a444901169

32
client
View file

@ -1,32 +0,0 @@
<?php
use \Reflect\Client;
use \Reflect\Method;
use \Reflect\Connection;
if (php_sapi_name() !== "cli") {
die("Must be run from command line\n");
}
require_once __DIR__ . "/src/Reflect/Client.php";
// Require 3 to 4 arguments
if ($argc < 4 || $argc > 4) {
$arglen = $argc - 1;
exit("Expected 3 to 4 arguments (got ${arglen}): <reflect_socket_path> <endpoint> <http_method> [payload]\n");
}
// Connect to the socket server
$client = new Client($argv[1], null, Connection::AF_UNIX);
// Get endpoint, method, and optional payload
$args = $argv;
array_shift($args);
array_shift($args);
// Restore enum from argument
$args[1] = Method::from(strtoupper($args[1]));
// Call endpoint and echo result
$call = $client->call(...$args);
echo json_encode($call) . "\n";