1
0
Fork 0
mirror of https://github.com/DanielnetoDotCom/YouPHPTube synced 2025-10-03 01:39:24 +02:00

Socket update

This commit is contained in:
Daniel Neto 2023-10-06 11:30:16 -03:00
parent 2ac02dab17
commit b39e5f4da6
5 changed files with 35 additions and 10 deletions

View file

@ -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);
}
}