Simplify event_socket code

This commit is contained in:
FusionPBX 2023-09-27 23:23:56 -06:00 committed by GitHub
parent 7246961b9f
commit bf8c6f8078
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 8 deletions

View File

@ -62,17 +62,19 @@ class event_socket {
$b = $this->buffer; $b = $this->buffer;
$content_length = 0; $content_length = 0;
$content = Array(); $content = array();
while (true) { while (true) {
while(($line = $b->read_line()) !== false ) { $line = $b->read_line();
if ($line == '') { if ($line !== false) {
break 2; if ($line === '') {
break;
} }
$kv = explode(':', $line, 2);
$content[trim($kv[0])] = trim($kv[1]);
} }
list($key, $value) = explode(':', $line, 2);
$content[trim($key)] = trim($value);
if (feof($this->fp)) { if (feof($this->fp)) {
break; break;
} }
@ -137,7 +139,7 @@ class event_socket {
socket_set_blocking($fp, true); socket_set_blocking($fp, true);
$this->fp = $fp; $this->fp = $fp;
// Wait auth request and send response //wait auth request and send response
while (!feof($fp)) { while (!feof($fp)) {
$event = $this->read_event(); $event = $this->read_event();
if(@$event['Content-Type'] == 'auth/request'){ if(@$event['Content-Type'] == 'auth/request'){
@ -146,7 +148,7 @@ class event_socket {
} }
} }
// Wait auth response //wait auth response
while (!feof($fp)) { while (!feof($fp)) {
$event = $this->read_event(); $event = $this->read_event();
if (@$event['Content-Type'] == 'command/reply') { if (@$event['Content-Type'] == 'command/reply') {