diff --git a/plugin/YPTSocket/MessageSQLite.php b/plugin/YPTSocket/MessageSQLite.php index 06ecdb6c41..41f544ceb4 100644 --- a/plugin/YPTSocket/MessageSQLite.php +++ b/plugin/YPTSocket/MessageSQLite.php @@ -59,7 +59,7 @@ class Message implements MessageComponentInterface { $live_key['liveLink'] = ''; } - + //_error_log(json_encode(array($json, $wsocketGetVars))); //var_dump($live_key); $client = array(); $client['resourceId'] = intval($conn->resourceId); @@ -141,6 +141,10 @@ class Message implements MessageComponentInterface { } $end = number_format(microtime(true) - $start, 4); _log_message("Connection opened in {$end} seconds"); + if(!empty($client['isCommandLine'])){ + _error_log('isCommandLine close it'); + $conn->close(); + } } public function onClose(ConnectionInterface $conn) { @@ -403,8 +407,8 @@ class Message implements MessageComponentInterface { $this->msgToResourceId($msg, $row['resourceId'], $type); } } - } catch (Exception $exc) { - echo $exc->getTraceAsString(); + } catch (\Throwable $th) { + echo $th->getTraceAsString(); } _log_message("msgToUsers_id: sent to ($count) clients users_id=" . json_encode($users_id)); @@ -457,6 +461,9 @@ class Message implements MessageComponentInterface { $totals = $this->getTotals(); foreach ($rows as $key => $client) { + if($client['isCommandLine']){ + continue; + } $this->msgToResourceId($msg, $client['resourceId'], $type, $totals); } $end = number_format(microtime(true) - $start, 4); @@ -473,6 +480,9 @@ class Message implements MessageComponentInterface { _log_message("msgToAllSameVideo: {$videos_id}"); $totals = $this->getTotals(); foreach (dbGetAllResourcesIdFromVideosId($videos_id) as $client) { + if($client['isCommandLine']){ + continue; + } $this->msgToResourceId($msg, $client['resourceId'], \SocketMessageType::ON_VIDEO_MSG, $totals); } } @@ -490,6 +500,9 @@ class Message implements MessageComponentInterface { $totals = $this->getTotals(); foreach ($rows as $value) { + if($value['isCommandLine']){ + continue; + } $this->msgToResourceId($msg, $value['resourceId'], \SocketMessageType::ON_LIVE_MSG, $totals); } } diff --git a/plugin/YPTSocket/YPTSocket.php b/plugin/YPTSocket/YPTSocket.php index afdcb725cd..e81d1423a0 100644 --- a/plugin/YPTSocket/YPTSocket.php +++ b/plugin/YPTSocket/YPTSocket.php @@ -41,7 +41,7 @@ class YPTSocket extends PluginAbstract { } public static function getServerVersion() { - return "4.3"; + return "4.4"; } public function updateScript() { @@ -151,6 +151,7 @@ class YPTSocket extends PluginAbstract { $SocketSendObj = new stdClass(); $SocketSendObj->msg = $msg; + $SocketSendObj->isCommandLine = isCommandLineInterface(); $SocketSendObj->json = _json_decode($msg); $SocketSendObj->webSocketToken = getEncryptedInfo(0, $send_to_uri_pattern); @@ -169,18 +170,20 @@ class YPTSocket extends PluginAbstract { \Ratchet\Client\connect($SocketURL)->then(function ($conn) { global $SocketSendObj, $SocketSendUsers_id, $SocketSendResponseObj; $conn->on('message', function ($msg) use ($conn, $SocketSendResponseObj) { - //echo "Received: {$msg}\n"; - //$conn->close(); + echo "Received: {$msg}".PHP_EOL; $SocketSendResponseObj->error = false; $SocketSendResponseObj->msg = $msg; + //$conn->close(); }); foreach ($SocketSendUsers_id as $users_id) { $SocketSendObj->to_users_id = $users_id; $conn->send(json_encode($SocketSendObj)); + echo "send: {$users_id}".PHP_EOL; } $conn->close(); + echo "close".PHP_EOL; //$SocketSendResponseObj->error = false; }, function ($e) { diff --git a/plugin/YPTSocket/db.php b/plugin/YPTSocket/db.php index feed908d08..0c0d6d835c 100644 --- a/plugin/YPTSocket/db.php +++ b/plugin/YPTSocket/db.php @@ -260,7 +260,7 @@ function dbGetTotalUniqueDevices() { function dbGetTotalConnections() { global $db; $sql = "SELECT count(resourceId) as total " - . "FROM `connections` "; + . "FROM `connections` WHERE (isCommandLine = 0 OR isCommandLine IS NULL)"; $sth = $db->prepare($sql); $sth->execute(); $result = $sth->fetch(); diff --git a/plugin/YPTSocket/footer.php b/plugin/YPTSocket/footer.php index e41ceeffc9..56b8d21439 100644 --- a/plugin/YPTSocket/footer.php +++ b/plugin/YPTSocket/footer.php @@ -246,6 +246,7 @@ if (!empty($obj->debugAllUsersSocket) || (User::isAdmin() && !empty($obj->debugS var webSocketVideos_id = ''; var webSocketLiveKey = ''; var webSocketServerVersion = ''; + var schedulerIsActive = ; var webSocketToken = ''; var webSocketURL = ''; var webSocketTypes = getConstants()); ?>; @@ -253,7 +254,7 @@ if (!empty($obj->debugAllUsersSocket) || (User::isAdmin() && !empty($obj->debugS function onUserSocketConnect(response) { try { - + } catch (e) { console.log('onUserSocketConnect:error', e.message); } diff --git a/plugin/YPTSocket/script.js b/plugin/YPTSocket/script.js index d658de69ee..c096a80001 100644 --- a/plugin/YPTSocket/script.js +++ b/plugin/YPTSocket/script.js @@ -234,7 +234,7 @@ async function AutoUpdateOnHTMLTimer() { }, 2000); } - +var canShowSocketToast = true; function parseSocketResponse() { json = yptSocketResponse; yptSocketResponse = false; @@ -244,8 +244,16 @@ function parseSocketResponse() { console.log("parseSocketResponse", json); //console.trace(); if (json.isAdmin && webSocketServerVersion > json.webSocketServerVersion) { - if (typeof avideoToastWarning == 'function') { + if (canShowSocketToast && typeof avideoToastWarning == 'function') { avideoToastWarning("Please restart your socket server. You are running (v" + json.webSocketServerVersion + ") and your client is expecting (v" + webSocketServerVersion + ")"); + + // Set the flag to false + canShowSocketToast = false; + + // Reset the flag after 5 minutes + setTimeout(function() { + canShowSocketToast = true; + }, 300000); // 300,000 milliseconds = 5 minutes } } if (json && typeof json.users_id_online !== 'undefined') {