diff --git a/package.json b/package.json index 0344a61..efa8c7c 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ "express": "^4.16.1", "helmet": "*", "socket.io": "^2.1.1", + "coffeescript": "*", "merge-stream": "*", "gulp": "*", "gulp-sourcemaps": "*", diff --git a/server/scripts/10-socket.coffee b/server/scripts/10-socket.coffee new file mode 100644 index 0000000..a89f626 --- /dev/null +++ b/server/scripts/10-socket.coffee @@ -0,0 +1,39 @@ +# libraries +http = require 'http' +socketio = require 'socket.io' +express = require 'express' +gulp = global.gulp = require 'gulp' +helmet = require 'helmet' + +# gulp the sources +require './gulpfile' +gulp.start 'default' + +# socket.io framework +app = express() +web = http.Server app +io = socketio web + +# Listen server +web.listen 8080, -> + console.log 'Node.js listening on port 8080' + +app.use helmet() + +# Static content +app.use ( express.static __dirname + '/../static' ) + +# Server logic +io.on 'connection', (socket) -> + console.log 'a user connected' + console.log socket.id + + socket.on 'disconnect', -> + # console.log 'user disconnected' + return + + socket.on 'login', -> + console.log 'message:', msg.uname, msg.password + return + + return