Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Neto committed Aug 7, 2024
1 parent e4120bc commit eb761e0
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 31 deletions.
31 changes: 1 addition & 30 deletions plugin/YPTSocket/MessageSQLiteV2.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

class Message implements MessageComponentInterface {
static $msgToAll = array();
static $msgToAllLogged = array();
static $mem_usage;
static $mem;
protected $clients;
Expand Down Expand Up @@ -48,10 +47,6 @@ public function initPeriodicTask() {
$this->_msgToAll(self::$msgToAll, \SocketMessageType::MSG_TO_ALL);
self::$msgToAll = array();
}
if(!empty(self::$msgToAllLogged)){
$this->_msgToAllLogged(self::$msgToAllLogged, \SocketMessageType::MSG_TO_ALL);
self::$msgToAllLogged = array();
}
});
}

Expand Down Expand Up @@ -181,7 +176,7 @@ public function onClose(ConnectionInterface $conn) {
_log_message("onClose {$conn->resourceId} has deleted");
$this->unsetClient($conn, $client);
if ($this->shouldPropagateInfo($client)) {
$this->msgToAllLogged(array('users_id' => $client['users_id'], 'disconnected'=>$conn->resourceId), \SocketMessageType::NEW_DISCONNECTION);
$this->msgToAll(array('users_id' => $client['users_id'], 'disconnected'=>$conn->resourceId), \SocketMessageType::NEW_DISCONNECTION);
}
_log_message("Connection {$conn->resourceId} has disconnected");
}
Expand Down Expand Up @@ -514,30 +509,6 @@ public function _msgToAll( $msg, $type = "") {
_log_message("msgToAll FROM {$type} Total Clients: " . count($rows) . " in {$end} seconds");
}

public function msgToAllLogged($msg, $type = "") {
self::$msgToAll[] = array('msg'=>$msg, 'type'=>$type,);
}

public function _msgToAllLogged($msg, $type = "") {
$start = microtime(true);
$rows = dbGetAll();

$totals = $this->getTotals();

foreach ($rows as $key => $client) {
if($client['isCommandLine']){
//_error_log("msgToAllLogged continue");
continue;
}
if(empty($client['users_id'])){
continue;
}
$this->msgToResourceId($msg, $client['resourceId'], $type, $totals);
}
$end = number_format(microtime(true) - $start, 4);
_log_message("msgToAll {$type} Total Clients: " . count($rows) . " in {$end} seconds");
}

public function msgToAllSameVideo($videos_id, $msg) {
if (empty($videos_id)) {
return false;
Expand Down
1 change: 1 addition & 0 deletions plugin/YPTSocket/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ function verifyTokenSocket($token) {

class SocketMessageType {

const MSG_TO_ALL_LOGGED = "MSG_TO_ALL_LOGGED";
const MSG_TO_ALL = "MSG_TO_ALL";
const OPEN_CONNECTION = "OPEN_CONNECTION";
const NEW_CONNECTION = "NEW_CONNECTION";
Expand Down
2 changes: 1 addition & 1 deletion plugin/YPTSocket/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ function socketConnect() {
yptSocketResponse = json;
parseSocketResponse();
if (json.type == webSocketTypes.MSG_TO_ALL && typeof json.msg == 'object' && Array.isArray(json.msg)) {
console.log("Socket onmessage MSG_TO_ALL ", json.msg.length, json);
console.log("Socket onmessage "+json.type, json.msg.length, json);
for (let index = 0; index < json.msg.length; index++) {
const element = json.msg[index];
processSocketJson(element);
Expand Down

0 comments on commit eb761e0

Please sign in to comment.