Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #3 from 4z3/master

update to node 0.10 & co.
  • Loading branch information...
commit c9865945d605c28bac25c141743f7f1d3448991d 2 parents c028aed + c8a280f
@pfleidi authored
View
1  .gitignore
@@ -1,3 +1,4 @@
*.swp
log/
static/content/
+/node_modules
View
22 mediengewitter.js
@@ -12,13 +12,15 @@
var Connect = require('connect'),
Fs = require('fs'),
-Log4js = require('log4js')(),
+Log4js = require('log4js'),
Io = require('socket.io'),
+Http = require('http'),
PORT = 8080,
WEBROOT = __dirname + '/static',
LOGFILE = __dirname + '/log/mediengewitter.log';
-Log4js.addAppender(Log4js.fileAppender(LOGFILE), 'mediengewitter');
+Log4js.loadAppender('file');
+Log4js.addAppender(Log4js.appenders.file(LOGFILE), 'mediengewitter');
var logger = Log4js.getLogger('mediengewitter');
logger.setLevel('DEBUG');
@@ -34,13 +36,17 @@ var logStream = Fs.createWriteStream(__dirname + '/log/access.log', {
flags: 'a'
});
-var httpServer = Connect.createServer(
- Connect.cache(),
- Connect.staticProvider(WEBROOT),
- Connect.gzip(),
+var app = Connect();
+var httpServer = Http.createServer(app);
+
+[
+ Connect.static(WEBROOT),
+ Connect.compress(),
Connect.logger(),
Connect.errorHandler({ showStack: true, dumpExceptions: true})
-);
+].forEach(function (middleware) {
+ app.use(middleware);
+});
httpServer.listen(PORT, function () {
logger.debug('Webserver successfully started.');
@@ -64,7 +70,7 @@ webSocketServer.on('connection', function (connection) {
var currImage = imageCache.nextImage();
logger.info("Current Image is : " + currImage);
var toSend = JSON.stringify({ data: 'content/' + currImage });
- webSocketServer.broadcast(toSend);
+ webSocketServer.sockets.send(toSend);
setTimeout(doAction, DELAY);
}());
View
8 package.json
@@ -0,0 +1,8 @@
+{
+ "dependencies": {
+ "connect": "*",
+ "connect-cache": "*",
+ "log4js": "*",
+ "socket.io": "*"
+ }
+}
View
3  static/js/mediengewitter-client.js
@@ -106,8 +106,7 @@
sections = [];
function connect() {
- var socket = new io.Socket(window.location.hostname, { port: window.location.port });
- socket.connect();
+ var socket = io.connect();
socket.on('message', function (data) {
var imageData = JSON.parse(data);
Please sign in to comment.
Something went wrong with that request. Please try again.