23 lines
562 B
PHP
23 lines
562 B
PHP
<?php namespace MapGuesser\Multi;
|
|
|
|
class MultiConnector
|
|
{
|
|
public function sendMessage(string $func, array $args = [])
|
|
{
|
|
$message = json_encode([
|
|
'func' => $func,
|
|
'args' => $args
|
|
]);
|
|
|
|
$connection = fsockopen($_ENV['MULTI_INTERNAL_HOST'], $_ENV['MULTI_INTERNAL_PORT']);
|
|
fwrite($connection, $message);
|
|
$response = '';
|
|
while (!feof($connection)) {
|
|
$response .= fgets($connection);
|
|
}
|
|
fclose($connection);
|
|
|
|
return json_decode($response, true);
|
|
}
|
|
}
|