2012-04-27 13:42:44 +00:00
|
|
|
###
|
|
|
|
# node.js Pushserver for Tims Chat.
|
|
|
|
#
|
|
|
|
# @author Tim Düsterhus
|
|
|
|
# @copyright 2010-2012 Tim Düsterhus
|
|
|
|
# @license Creative Commons Attribution-NonCommercial-ShareAlike <http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode>
|
|
|
|
# @package be.bastelstu.wcf.chat
|
|
|
|
###
|
2012-04-27 17:33:28 +00:00
|
|
|
process.title = 'Tims Chat Pushserver'
|
2012-04-27 13:42:44 +00:00
|
|
|
|
|
|
|
io = require 'socket.io'
|
2012-04-27 17:33:28 +00:00
|
|
|
net = require 'net'
|
2012-04-27 13:42:44 +00:00
|
|
|
|
|
|
|
config = require('../config.js').config
|
|
|
|
|
|
|
|
log = (message) ->
|
|
|
|
console.log '[be.bastelstu.wcf.chat.serverPush] '+message
|
|
|
|
|
|
|
|
class Server
|
|
|
|
constructor: () ->
|
|
|
|
log 'Starting Pushserver for Tims Chat'
|
2012-04-27 17:33:28 +00:00
|
|
|
log 'PID is ' + process.pid
|
2012-04-27 13:42:44 +00:00
|
|
|
log 'Using port: ' + config.port
|
|
|
|
|
2012-04-27 17:33:28 +00:00
|
|
|
@initUnixSocket()
|
|
|
|
@initSocketIO()
|
|
|
|
initSocketIO: () ->
|
2012-04-27 13:42:44 +00:00
|
|
|
@socket = io.listen config.port
|
|
|
|
|
2012-04-27 14:20:41 +00:00
|
|
|
@socket.set 'log level', 1
|
|
|
|
@socket.set 'browser client etag', true
|
|
|
|
@socket.set 'browser client minification', true
|
|
|
|
@socket.set 'browser client gzig', true
|
|
|
|
|
|
|
|
@socket.configure 'development', (() ->
|
|
|
|
@socket.set 'log level', 3
|
|
|
|
@socket.set 'browser client etag', false
|
|
|
|
@socket.set 'browser client minification', false
|
|
|
|
).bind(@)
|
2012-04-27 17:33:28 +00:00
|
|
|
initUnixSocket: () ->
|
|
|
|
log 'Initializing Unix-Socket'
|
|
|
|
socket = net.createServer ((c) ->
|
2012-04-27 13:42:44 +00:00
|
|
|
@socket.sockets.emit 'newMessage'
|
2012-04-27 17:33:28 +00:00
|
|
|
c.end()
|
|
|
|
).bind(@)
|
|
|
|
|
|
|
|
socket.listen process.cwd() + '/../data.sock'
|
2012-04-27 13:42:44 +00:00
|
|
|
|
|
|
|
new Server()
|