mirror of
https://github.com/wbbaddons/Tims-Chat.git
synced 2025-01-09 00:20:08 +00:00
PHP now triggers newMessage-event
This commit is contained in:
parent
38f4d76694
commit
58ec55bed2
@ -6,8 +6,10 @@
|
|||||||
# @license Creative Commons Attribution-NonCommercial-ShareAlike <http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode>
|
# @license Creative Commons Attribution-NonCommercial-ShareAlike <http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode>
|
||||||
# @package be.bastelstu.wcf.chat
|
# @package be.bastelstu.wcf.chat
|
||||||
###
|
###
|
||||||
|
process.title = 'Tims Chat Pushserver'
|
||||||
|
|
||||||
io = require 'socket.io'
|
io = require 'socket.io'
|
||||||
|
net = require 'net'
|
||||||
|
|
||||||
config = require('../config.js').config
|
config = require('../config.js').config
|
||||||
|
|
||||||
@ -17,8 +19,12 @@ log = (message) ->
|
|||||||
class Server
|
class Server
|
||||||
constructor: () ->
|
constructor: () ->
|
||||||
log 'Starting Pushserver for Tims Chat'
|
log 'Starting Pushserver for Tims Chat'
|
||||||
|
log 'PID is ' + process.pid
|
||||||
log 'Using port: ' + config.port
|
log 'Using port: ' + config.port
|
||||||
|
|
||||||
|
@initUnixSocket()
|
||||||
|
@initSocketIO()
|
||||||
|
initSocketIO: () ->
|
||||||
@socket = io.listen config.port
|
@socket = io.listen config.port
|
||||||
|
|
||||||
@socket.set 'log level', 1
|
@socket.set 'log level', 1
|
||||||
@ -31,9 +37,13 @@ class Server
|
|||||||
@socket.set 'browser client etag', false
|
@socket.set 'browser client etag', false
|
||||||
@socket.set 'browser client minification', false
|
@socket.set 'browser client minification', false
|
||||||
).bind(@)
|
).bind(@)
|
||||||
|
initUnixSocket: () ->
|
||||||
setInterval((() ->
|
log 'Initializing Unix-Socket'
|
||||||
|
socket = net.createServer ((c) ->
|
||||||
@socket.sockets.emit 'newMessage'
|
@socket.sockets.emit 'newMessage'
|
||||||
).bind(@), 5000)
|
c.end()
|
||||||
|
).bind(@)
|
||||||
|
|
||||||
|
socket.listen process.cwd() + '/../data.sock'
|
||||||
|
|
||||||
new Server()
|
new Server()
|
@ -16,6 +16,22 @@ class ChatMessageEditor extends \wcf\data\DatabaseObjectEditor {
|
|||||||
*/
|
*/
|
||||||
protected static $baseClass = '\wcf\data\chat\message\ChatMessage';
|
protected static $baseClass = '\wcf\data\chat\message\ChatMessage';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notify the Push-Server.
|
||||||
|
*/
|
||||||
|
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')) {
|
||||||
|
$sock = stream_socket_client('unix://data.sock', $errno, $errstr, 1);
|
||||||
|
fclose($sock);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (\Exception $e) { }
|
||||||
|
|
||||||
|
return parent::create($parameters);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes old messages.
|
* Removes old messages.
|
||||||
|
Loading…
Reference in New Issue
Block a user