From 3ba9cf71432f29277d73072f404b7d5b019a9781 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Mon, 30 Apr 2012 20:51:27 +0200 Subject: [PATCH] serverPush -> nodePush --- build.php | 6 +++--- .../.gitignore | 0 .../README.md | 0 .../bin/run.sh | 4 ++-- .../config.js | 0 .../lib/server.coffee | 6 ++++-- .../package.json | 9 +++------ .../data/chat/message/ChatMessageEditor.class.php | 8 +++----- file/lib/util/ChatUtil.class.php | 15 ++++++++++++++- 9 files changed, 29 insertions(+), 19 deletions(-) rename file/acp/{be.bastelstu.wcf.chat.serverPush => be.bastelstu.wcf.chat.nodePush}/.gitignore (100%) rename file/acp/{be.bastelstu.wcf.chat.serverPush => be.bastelstu.wcf.chat.nodePush}/README.md (100%) rename file/acp/{be.bastelstu.wcf.chat.serverPush => be.bastelstu.wcf.chat.nodePush}/bin/run.sh (71%) rename file/acp/{be.bastelstu.wcf.chat.serverPush => be.bastelstu.wcf.chat.nodePush}/config.js (100%) rename file/acp/{be.bastelstu.wcf.chat.serverPush => be.bastelstu.wcf.chat.nodePush}/lib/server.coffee (89%) rename file/acp/{be.bastelstu.wcf.chat.serverPush => be.bastelstu.wcf.chat.nodePush}/package.json (65%) diff --git a/build.php b/build.php index 6289256..5436fe6 100755 --- a/build.php +++ b/build.php @@ -25,7 +25,7 @@ if (file_exists('file.tar')) unlink('file.tar'); if (file_exists('template.tar')) unlink('template.tar'); if (file_exists('acptemplate.tar')) unlink('acptemplate.tar'); - foreach (glob('file/acp/be.bastelstu.wcf.chat.serverPush/lib/*.js') as $nodeFile) unlink($nodeFile); + foreach (glob('file/acp/be.bastelstu.wcf.chat.nodePush/lib/*.js') as $nodeFile) unlink($nodeFile); foreach (glob('file/js/*.js') as $jsFile) unlink($jsFile); foreach (glob('file/style/*.css') as $cssFile) unlink($cssFile); if (file_exists('be.bastelstu.wcf.chat.tar')) unlink('be.bastelstu.wcf.chat.tar'); @@ -40,7 +40,7 @@ passthru('coffee -cb '.escapeshellarg($coffeeFile), $code); if ($code != 0) exit($code); } -foreach (glob('file/acp/be.bastelstu.wcf.chat.serverPush/lib/*.coffee') as $coffeeFile) { +foreach (glob('file/acp/be.bastelstu.wcf.chat.nodePush/lib/*.coffee') as $coffeeFile) { echo $coffeeFile."\n"; passthru('coffee -cb '.escapeshellarg($coffeeFile), $code); if ($code != 0) exit($code); @@ -124,6 +124,6 @@ if (file_exists('file.tar')) unlink('file.tar'); if (file_exists('template.tar')) unlink('template.tar'); if (file_exists('acptemplate.tar')) unlink('acptemplate.tar'); -foreach (glob('file/acp/be.bastelstu.wcf.chat.serverPush/lib/*.js') as $nodeFile) unlink($nodeFile); +foreach (glob('file/acp/be.bastelstu.wcf.chat.nodePush/lib/*.js') as $nodeFile) unlink($nodeFile); foreach (glob('file/js/*.js') as $jsFile) unlink($jsFile); foreach (glob('file/style/*.css') as $cssFile) unlink($cssFile); diff --git a/file/acp/be.bastelstu.wcf.chat.serverPush/.gitignore b/file/acp/be.bastelstu.wcf.chat.nodePush/.gitignore similarity index 100% rename from file/acp/be.bastelstu.wcf.chat.serverPush/.gitignore rename to file/acp/be.bastelstu.wcf.chat.nodePush/.gitignore diff --git a/file/acp/be.bastelstu.wcf.chat.serverPush/README.md b/file/acp/be.bastelstu.wcf.chat.nodePush/README.md similarity index 100% rename from file/acp/be.bastelstu.wcf.chat.serverPush/README.md rename to file/acp/be.bastelstu.wcf.chat.nodePush/README.md diff --git a/file/acp/be.bastelstu.wcf.chat.serverPush/bin/run.sh b/file/acp/be.bastelstu.wcf.chat.nodePush/bin/run.sh similarity index 71% rename from file/acp/be.bastelstu.wcf.chat.serverPush/bin/run.sh rename to file/acp/be.bastelstu.wcf.chat.nodePush/bin/run.sh index 6c9c30c..bebb77f 100755 --- a/file/acp/be.bastelstu.wcf.chat.serverPush/bin/run.sh +++ b/file/acp/be.bastelstu.wcf.chat.nodePush/bin/run.sh @@ -6,12 +6,12 @@ if [ -d "bin" ]; then fi if [ "$(id -u)" -eq 0 ]; then - echo "You may not start the Push-Server as root!" + echo "You may not start nodePush as root!" exit 1 fi echo "Installing dependencies" -npm install +/usr/bin/env npm install cd "../lib" diff --git a/file/acp/be.bastelstu.wcf.chat.serverPush/config.js b/file/acp/be.bastelstu.wcf.chat.nodePush/config.js similarity index 100% rename from file/acp/be.bastelstu.wcf.chat.serverPush/config.js rename to file/acp/be.bastelstu.wcf.chat.nodePush/config.js diff --git a/file/acp/be.bastelstu.wcf.chat.serverPush/lib/server.coffee b/file/acp/be.bastelstu.wcf.chat.nodePush/lib/server.coffee similarity index 89% rename from file/acp/be.bastelstu.wcf.chat.serverPush/lib/server.coffee rename to file/acp/be.bastelstu.wcf.chat.nodePush/lib/server.coffee index 2502ea4..868302d 100644 --- a/file/acp/be.bastelstu.wcf.chat.serverPush/lib/server.coffee +++ b/file/acp/be.bastelstu.wcf.chat.nodePush/lib/server.coffee @@ -5,8 +5,9 @@ # @copyright 2010-2012 Tim Düsterhus # @license Creative Commons Attribution-NonCommercial-ShareAlike # @package be.bastelstu.wcf.chat +# @subpackage nodePush ### -process.title = 'Tims Chat Pushserver' +process.title = 'nodePush - Tims Chat' io = require 'socket.io' net = require 'net' @@ -15,7 +16,7 @@ fs = require 'fs' config = require('../config.js').config log = (message) -> - console.log '[be.bastelstu.wcf.chat.serverPush] '+message + console.log '[be.bastelstu.wcf.chat.nodePush] '+message class Server constructor: () -> @@ -26,6 +27,7 @@ class Server @initUnixSocket() @initSocketIO() initSocketIO: () -> + log 'Initializing socket.io' @socket = io.listen config.port @socket.set 'log level', 1 diff --git a/file/acp/be.bastelstu.wcf.chat.serverPush/package.json b/file/acp/be.bastelstu.wcf.chat.nodePush/package.json similarity index 65% rename from file/acp/be.bastelstu.wcf.chat.serverPush/package.json rename to file/acp/be.bastelstu.wcf.chat.nodePush/package.json index 6140264..8438766 100644 --- a/file/acp/be.bastelstu.wcf.chat.serverPush/package.json +++ b/file/acp/be.bastelstu.wcf.chat.nodePush/package.json @@ -1,6 +1,6 @@ { - "name" : "be.bastelstu.wcf.chat.serverPush", - "description" : "Server-Pushing for Tims Chat", + "name" : "be.bastelstu.wcf.chat.nodePush", + "description" : "node.js-Pushing for Tims Chat", "homepage" : "https://github.com/wbbaddons/Tims-Chat", "keywords" : ["chat"], "author" : "Tim Düsterhus ", @@ -9,11 +9,8 @@ "dependencies" : { "socket.io" : "0.8.7" }, - "devDependencies": { - "jshint" : "*" - }, "engines" : { "node" : ">=0.6.0", "npm" : ">=1.0" }, - "version" : "1.0.0" + "version" : "3.0.0 Alpha 1" } diff --git a/file/lib/data/chat/message/ChatMessageEditor.class.php b/file/lib/data/chat/message/ChatMessageEditor.class.php index 0b02865..2ca31f1 100644 --- a/file/lib/data/chat/message/ChatMessageEditor.class.php +++ b/file/lib/data/chat/message/ChatMessageEditor.class.php @@ -21,11 +21,9 @@ class ChatMessageEditor extends \wcf\data\DatabaseObjectEditor { */ public static function create(array $parameters = array()) { try { - if (CHAT_SOCKET_IO_PATH) { - if (file_exists(WCF_DIR.'acp/be.bastelstu.wcf.chat.serverPush/data.sock') && is_writable(WCF_DIR.'acp/be.bastelstu.wcf.chat.serverPush/data.sock')) { - $sock = stream_socket_client('unix://'.WCF_DIR.'acp/be.bastelstu.wcf.chat.serverPush/data.sock', $errno, $errstr, 1); - fclose($sock); - } + if (\wcf\util\ChatUtil::nodePushRunning()) + $sock = stream_socket_client('unix://'.WCF_DIR.'acp/be.bastelstu.wcf.chat.nodePush/data.sock', $errno, $errstr, 1); + fclose($sock); } } catch (\Exception $e) { } diff --git a/file/lib/util/ChatUtil.class.php b/file/lib/util/ChatUtil.class.php index e701467..002baf7 100644 --- a/file/lib/util/ChatUtil.class.php +++ b/file/lib/util/ChatUtil.class.php @@ -45,7 +45,7 @@ final class ChatUtil { */ public static function getDiedUsers() { $packageID = \wcf\util\ChatUtil::getPackageID(); - if (CHAT_SOCKET_IO_PATH && file_exists(WCF_DIR.'acp/be.bastelstu.wcf.chat.serverPush/data.sock') && is_writable(WCF_DIR.'acp/be.bastelstu.wcf.chat.serverPush/data.sock')) { + if (self::nodePushRunning()) { $sql = "SELECT time FROM @@ -133,6 +133,19 @@ public static function gradient($string, $start, $end) { return $result; } + /** + * Checks whether nodePush is running. + * + * @return boolean + */ + public static function nodePushRunning() { + if (!CHAT_SOCKET_IO_PATH) return false; + if (!file_exists(WCF_DIR.'acp/be.bastelstu.wcf.chat.serverPush/data.sock')) return false; + if (!is_writable(WCF_DIR.'acp/be.bastelstu.wcf.chat.serverPush/data.sock')) return false; + + return true; + } + /** * Reads user data. *