From 7fdb3644e762aab9b07c9b6912f3c0f6845984c1 Mon Sep 17 00:00:00 2001 From: frytimo Date: Fri, 17 Oct 2025 16:45:49 -0300 Subject: [PATCH] Fix websocket connection (#7581) --- resources/classes/event_socket.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/resources/classes/event_socket.php b/resources/classes/event_socket.php index c35ea2775b..8a29c4422c 100644 --- a/resources/classes/event_socket.php +++ b/resources/classes/event_socket.php @@ -47,6 +47,12 @@ class buffer { * @depends buffer::class */ class event_socket { + /** + * Used as a flag to determine if the socket should be created automatically + * @var bool + */ + protected $auto_create; + private $buffer; public $fp; @@ -59,6 +65,7 @@ class event_socket { */ public function __construct($fp = false, ?config $config = null) { $this->buffer = new buffer; + $this->auto_create = $fp === false; $this->fp = $fp; $this->config = $config ?? config::load(); } @@ -143,7 +150,7 @@ class event_socket { $password = $password ?? $this->config->get('switch.event_socket.password', null) ?? $this->config->get('event_socket.password', null) ?? 'ClueCon'; //if a socket was provided in the constructor, then don't create a new one - if ($this->fp === false || !$this->connected()) { + if ($this->fp === false || $this->auto_create) { //open the socket connection $this->fp = @fsockopen($host, $port, $errno, $errdesc, 3); }