This repository has been archived on 2024-04-29. You can view files and clone it, but cannot push or open issues or pull requests.
node-fftcg/server.js

40 lines
812 B
JavaScript
Raw Normal View History

2018-09-30 18:21:59 +00:00
// libraries
var
http = require('http'),
socketio = require('socket.io'),
2018-09-30 21:23:05 +00:00
express = require('express'),
2018-10-02 00:17:04 +00:00
gulp = global.gulp = require('gulp'),
helmet = require('helmet');
2018-09-30 21:23:05 +00:00
// gulp the sources
require('./gulpfile');
gulp.start('default');
2018-09-30 18:21:59 +00:00
// socket.io framework
let app = express();
let web = http.Server(app);
let io = socketio(web);
// Listen server
web.listen(8080, function () {
console.log('Node.js listening on port 8080');
2018-09-30 18:21:59 +00:00
});
2018-10-02 00:17:04 +00:00
app.use(helmet());
2018-09-30 18:21:59 +00:00
// Static content
app.use(express.static(__dirname + '/static'));
// Server logic
io.on('connection', function (socket) {
console.log('a user connected');
socket.on('disconnect', function(){
// console.log('user disconnected');
});
socket.on('login', function(msg){
console.log('message:', msg.uname, msg.password);
});
2018-09-30 18:21:59 +00:00
});