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

@@ -595,10 +595,10 @@
//send the message waiting status
$fp = event_socket_create();
if ($fp) {
$esl = event_socket::create();
if ($esl->is_connected()) {
$switch_cmd = "luarun app.lua voicemail mwi ".$this->voicemail_id."@".$_SESSION['domain_name'];
$switch_result = event_socket_request($fp, 'api '.$switch_cmd);
$switch_result = event_socket::api($switch_cmd);
}
}
@@ -843,7 +843,7 @@
* range download method (helps safari play audio sources)
*/
private function range_download($file) {
$fp = @fopen($file, 'rb');
$esl = @fopen($file, 'rb');
$size = filesize($file); // File size
$length = $size; // Content length
@@ -909,7 +909,7 @@
$start = $c_start;
$end = $c_end;
$length = $end - $start + 1; // Calculate new content length
fseek($fp, $start);
fseek($esl, $start);
header('HTTP/1.1 206 Partial Content');
}
// Notify the client the byte range we'll be outputting
@@ -918,14 +918,14 @@
// Start buffered download
$buffer = 1024 * 8;
while(!feof($fp) && ($p = ftell($fp)) <= $end) {
while(!feof($esl) && ($p = ftell($esl)) <= $end) {
if ($p + $buffer > $end) {
// In case we're only outputtin a chunk, make sure we don't
// read past the length
$buffer = $end - $p + 1;
}
set_time_limit(0); // Reset time limit for big files
echo fread($fp, $buffer);
echo fread($esl, $buffer);
flush(); // Free up memory. Otherwise large files will trigger PHP's memory limit.
}