Event socket bug fix and more docs (#6823)

* Add documentation to methods. Use is_resource for added type detection

* Allow connect to specify timeout in microseconds with default 30,000

* Update calling mechanism for event sockets

* Update project for new singleton event sockets

* remove unused variable

* catch errors on closing the socket
This commit is contained in:
frytimo
2023-12-02 20:16:18 -04:00
committed by GitHub
parent 44567f7a05
commit 3a4c2f72e2
74 changed files with 1620 additions and 1533 deletions

View File

@@ -29,29 +29,39 @@
//includes files
require_once __DIR__ . "/require.php";
/**
* Returns an fp connector from an event socket.
* This has been replaced with event_socket::create() method and using the
* socket directly is preferred.
* @param string $host
* @param string $port
* @param string $password
* @return true Returns true if successful connection and false if there is a failure
* @deprecated since version 5.1.11
*/
function event_socket_create($host = null, $port = null, $password = null) {
$esl = new event_socket;
if ($esl->connect($host, $port, $password)) {
return $esl->reset_fp();
}
return false;
$esl = event_socket::create($host = null, $port = null, $password = null);
return ($esl !== false);
}
/**
* Makes a request on the event socket
* @param null $fp No longer used
* @param string $cmd Command to use
* @return string|false Response of the server or false if failed
*/
function event_socket_request($fp, $cmd) {
$esl = new event_socket($fp);
$result = $esl->request($cmd);
$esl->reset_fp();
return $result;
return event_socket::command($cmd);
}
/**
* Makes a request on the event socket
* @param type $fp
* @param type $cmd
* @return type
*/
function event_socket_request_cmd($cmd) {
$esl = new event_socket;
if (!$esl->connect()) {
return false;
}
$response = $esl->request($cmd);
$esl->close();
return $response;
return event_socket::command($cmd);
}
function remove_config_from_cache($name) {