Improvements in the way that STDOUT output is handled (turns out the constant

exists in PHP >= 4.3 and it's not defined() at all).

Don't let delete_old_users() kill sockets-type clients, we can do that on
our own, thank you.

Comment some trace()s.
This commit is contained in:
defacer
2004-08-24 13:58:01 +00:00
parent 75c180d2e3
commit f11d5ccb4f
2 changed files with 8 additions and 7 deletions
+5 -5
View File
@@ -68,13 +68,12 @@ class ChatDaemon {
var $message_queue = array(); // Holds messages that we haven't committed to the DB yet
function ChatDaemon() {
// Check the STDOUT constant
$this->_trace_to_stdout = defined('STDOUT');
$this->_trace_level = E_ALL ^ E_USER_NOTICE;
$this->_pcntl_exists = function_exists('pcntl_fork');
$this->_time_rest_socket = 20;
$this->_beepsoundsrc = $GLOBALS['CFG']->wwwroot.'/mod/chat/beep.wav';
$this->_freq_update_records = 15;
$this->_stdout = fopen('php://stdout', 'w');
}
function query_start() {
@@ -102,7 +101,8 @@ class ChatDaemon {
// Emit the message to wherever we should
if($this->_trace_to_stdout) {
fwrite(STDOUT, $message);
fwrite($this->_stdout, $message);
fflush($this->_stdout);
}
if($this->_trace_to_console) {
echo $message;
@@ -323,7 +323,7 @@ class ChatDaemon {
if($this->sets_info[$sessionid]['lastmessageindex'] >= $messageindex) {
// We have already broadcasted that!
$this->trace('discarding message with stale index');
// $this->trace('discarding message with stale index');
break;
}
else {
@@ -437,7 +437,7 @@ class ChatDaemon {
'quirks' => $customdata['quirks']
);
$this->trace('QUIRKS value for this connection is '.$customdata['quirks']);
// $this->trace('QUIRKS value for this connection is '.$customdata['quirks']);
$this->dismiss_half($sessionid, false);
chat_socket_write($this->conn_sets[$sessionid][CHAT_CONNECTION_CHANNEL], $CHAT_HTMLHEAD_JS);
+3 -2
View File
@@ -366,9 +366,10 @@ function chat_delete_old_users() {
global $CFG;
$timeold = time() - $CFG->chat_old_ping;
$query = "lastping < '$timeold' AND version != 'sockets'";
if ($oldusers = get_records_select("chat_users", "lastping < '$timeold'") ) {
delete_records_select("chat_users", "lastping < '$timeold'");
if ($oldusers = get_records_select("chat_users", $query) ) {
delete_records_select("chat_users", $query);
foreach ($oldusers as $olduser) {
$message->chatid = $olduser->chatid;
$message->userid = $olduser->userid;