mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 08:56:36 +02:00
Better comments and some more diagnostic messages to help with bug hunting.
Also changed a > to >= to make the polling interval precice to the second.
This commit is contained in:
parent
102b9d710e
commit
bc6c7c26b6
1 changed files with 7 additions and 1 deletions
|
@ -84,6 +84,9 @@ class ChatDaemon {
|
||||||
var $sets_info = array(); // Keyed by sessionid exactly like conn_sets, one of these for each of those
|
var $sets_info = array(); // Keyed by sessionid exactly like conn_sets, one of these for each of those
|
||||||
var $chatrooms = array(); // Keyed by chatid, holding arrays of data
|
var $chatrooms = array(); // Keyed by chatid, holding arrays of data
|
||||||
|
|
||||||
|
// IMPORTANT: $conn_sets, $sets_info and $chatrooms must remain synchronized!
|
||||||
|
// Pay extra attention when you write code that affects any of them!
|
||||||
|
|
||||||
function ChatDaemon() {
|
function ChatDaemon() {
|
||||||
$this->_trace_level = E_ALL ^ E_USER_NOTICE;
|
$this->_trace_level = E_ALL ^ E_USER_NOTICE;
|
||||||
$this->_pcntl_exists = function_exists('pcntl_fork');
|
$this->_pcntl_exists = function_exists('pcntl_fork');
|
||||||
|
@ -113,7 +116,9 @@ class ChatDaemon {
|
||||||
if(!empty($chatroom['users'])) {
|
if(!empty($chatroom['users'])) {
|
||||||
foreach($chatroom['users'] as $sessionid => $userid) {
|
foreach($chatroom['users'] as $sessionid => $userid) {
|
||||||
// We will be polling each user as required
|
// We will be polling each user as required
|
||||||
|
$this->trace('...shall we poll '.$sessionid.'?');
|
||||||
if($this->sets_info[$sessionid]['chatuser']->lastmessageping < $this->_last_idle_poll) {
|
if($this->sets_info[$sessionid]['chatuser']->lastmessageping < $this->_last_idle_poll) {
|
||||||
|
$this->trace('YES!');
|
||||||
// This user hasn't been polled since his last message
|
// This user hasn't been polled since his last message
|
||||||
if($this->write_data($this->conn_sets[$sessionid][CHAT_CONNECTION_CHANNEL], '<!-- poll -->') === false) {
|
if($this->write_data($this->conn_sets[$sessionid][CHAT_CONNECTION_CHANNEL], '<!-- poll -->') === false) {
|
||||||
// User appears to have disconnected
|
// User appears to have disconnected
|
||||||
|
@ -627,6 +632,7 @@ class ChatDaemon {
|
||||||
unset($this->conn_sets[$sessionid]);
|
unset($this->conn_sets[$sessionid]);
|
||||||
unset($this->sets_info[$sessionid]);
|
unset($this->sets_info[$sessionid]);
|
||||||
unset($this->chatrooms[$chatroom]['users'][$sessionid]);
|
unset($this->chatrooms[$chatroom]['users'][$sessionid]);
|
||||||
|
$this->trace('Removed all traces of user with session '.$sessionid, E_USER_NOTICE);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1036,7 +1042,7 @@ while(true) {
|
||||||
$now = time();
|
$now = time();
|
||||||
|
|
||||||
// Clean up chatrooms with no activity as required
|
// Clean up chatrooms with no activity as required
|
||||||
if($now - $DAEMON->_last_idle_poll > $DAEMON->_freq_poll_idle_chat) {
|
if($now - $DAEMON->_last_idle_poll >= $DAEMON->_freq_poll_idle_chat) {
|
||||||
$DAEMON->poll_idle_chats($now);
|
$DAEMON->poll_idle_chats($now);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue