From 15d9f021336a82beb20a8d0c50530f8daa0cf55b Mon Sep 17 00:00:00 2001 From: jkaplon Date: Wed, 9 Nov 2016 11:14:32 -0500 Subject: [PATCH] Basic socket.io event is working. --- package.json | 1 + server.js | 12 +++++++++++- views/index.hbs | 7 ++++++- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 4f90403..8810d20 100644 --- a/package.json +++ b/package.json @@ -15,6 +15,7 @@ "passport-local": "^1.0.0", "pg": "^4.4.3", "serve-favicon": "^2.3.0", + "socket.io": "^1.5.1", "sqlite3": "^3.0.8", "winston": "^2.1.1" }, diff --git a/server.js b/server.js index 838929f..3b7b73d 100644 --- a/server.js +++ b/server.js @@ -140,6 +140,16 @@ app.get('/logout', function(req, res){ res.redirect('/'); }); -app.listen(3000, function() { +var http = require('http').Server(app); +var io = require('socket.io')(http); + +io.on('connection', function(socket){ + //winston.info('a user connected'); + socket.on('cm-save', function(msg){ + winston.info(msg); + }); +}); + +http.listen(3000, function() { winston.info("Started on PORT 3000"); }); diff --git a/views/index.hbs b/views/index.hbs index fc1aa0b..a5492f3 100644 --- a/views/index.hbs +++ b/views/index.hbs @@ -16,6 +16,7 @@ +