From ca790587f29588c7d0d2f15f0e822fbad6e1c43a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Sat, 19 May 2012 17:43:24 +0200 Subject: [PATCH] Trigger message loading once a minute for easier detection of dead users. Closes #9 --- .../be.bastelstu.wcf.chat.nodePush/lib/server.coffee | 4 ++++ file/lib/util/ChatUtil.class.php | 12 +----------- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/file/acp/be.bastelstu.wcf.chat.nodePush/lib/server.coffee b/file/acp/be.bastelstu.wcf.chat.nodePush/lib/server.coffee index 1360bdb..29554c0 100644 --- a/file/acp/be.bastelstu.wcf.chat.nodePush/lib/server.coffee +++ b/file/acp/be.bastelstu.wcf.chat.nodePush/lib/server.coffee @@ -29,6 +29,10 @@ class Server @initUnixSocket() @initSocketIO() + + setInterval (() -> + @socket.sockets.emit 'newMessage' + ).bind(@), 60e3 initSocketIO: () -> log 'Initializing socket.io' @socket = io.listen config.port diff --git a/file/lib/util/ChatUtil.class.php b/file/lib/util/ChatUtil.class.php index 002baf7..7fff536 100644 --- a/file/lib/util/ChatUtil.class.php +++ b/file/lib/util/ChatUtil.class.php @@ -46,17 +46,7 @@ final class ChatUtil { public static function getDiedUsers() { $packageID = \wcf\util\ChatUtil::getPackageID(); if (self::nodePushRunning()) { - $sql = "SELECT - time - FROM - wcf".WCF_N."_chat_message - WHERE - time < ? - ORDER BY - messageID DESC"; - $stmt = WCF::getDB()->prepareStatement($sql, 1, 1); - $stmt->execute(array(TIME_NOW - 10)); - $time = $stmt->fetchColumn(); + $time = TIME_NOW - 120; } else { $time = TIME_NOW;