Fix regression error in publish.php

- We still need the function "curl_socket"
This commit is contained in:
bergware
2023-11-28 13:51:46 +01:00
parent 4d4a52fc5e
commit 9a8fe9d80b

View File

@@ -11,9 +11,9 @@
*/
?>
<?
function publish($endpoint, $message, $len=1) {
$com = curl_init("http://localhost/pub/$endpoint?buffer_length=$len");
curl_setopt_array($com, [CURLOPT_UNIX_SOCKET_PATH => "/var/run/nginx.socket", CURLOPT_HTTPHEADER => ['Accept:text/json'], CURLOPT_RETURNTRANSFER => 1]);
function curl_socket($socket, $url, $message) {
$com = curl_init($url);
curl_setopt_array($com, [CURLOPT_UNIX_SOCKET_PATH => $socket, CURLOPT_HTTPHEADER => ['Accept:text/json'], CURLOPT_RETURNTRANSFER => 1]);
$reply = json_decode(curl_exec($com),true);
// only send message when active subscribers are present
if (($reply['subscribers']??0)>0) {
@@ -24,4 +24,8 @@ function publish($endpoint, $message, $len=1) {
// return number of active subscribers
return $reply['subscribers']??0;
}
function publish($endpoint, $message, $len=1) {
return curl_socket("/var/run/nginx.socket", "http://localhost/pub/$endpoint?buffer_length=$len", $message);
}
?>