added basic socketio

This commit is contained in:
Lukas Bachschwell 2017-03-13 13:43:15 +01:00
parent 9d2ab052a4
commit 34a70b4d41
4 changed files with 24 additions and 9 deletions

23
app.js
View File

@ -1,13 +1,19 @@
var express = require('express');
var path = require('path');
var favicon = require('serve-favicon');
var logger = require('morgan');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
let express = require('express'),
path = require('path'),
favicon = require('serve-favicon'),
logger = require('morgan'),
cookieParser = require('cookie-parser'),
bodyParser = require('body-parser'),
socketio = require('socket.io');
var routes = require('./routes/routes');
let routes = require('./routes/routes'),
app = express();
let io = socketio();
app.io = io;
// let io = socketio.listen(app);
var app = express();
// view engine setup
app.set('views', path.join(__dirname, 'views'));
@ -55,4 +61,5 @@ app.use(function(err, req, res, next) {
});
module.exports = app;

View File

@ -21,6 +21,13 @@ app.set('port', port);
var server = http.createServer(app);
/**
* Socket.io
*/
var io = app.io;
io.attach( server );
/**
* Listen on provided port, on all network interfaces.
*/

View File

@ -7,7 +7,7 @@
6 silly lifecycle uniScore@1.0.0~prestart: no script for prestart, continuing
7 info lifecycle uniScore@1.0.0~start: uniScore@1.0.0
8 verbose lifecycle uniScore@1.0.0~start: unsafe-perm in lifecycle true
9 verbose lifecycle uniScore@1.0.0~start: PATH: /usr/local/lib/node_modules/npm/bin/node-gyp-bin:/Users/LB/Desktop/z_Projects/uniScore/node_modules/.bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/go/bin:/usr/local/MacGPG2/bin:/Library/TeX/texbin:/Users/LB/.rvm/bin:/Users/LB/pebble-dev/PebbleSDK-3.6/bin:/usr/local/sbin:/Users/LB/Library/Android/sdk/platform-tools:/Users/LB/.rvm/bin:/Users/LB/pebble-dev/PebbleSDK-3.6/bin:/usr/local/sbin:/Users/LB/Library/Android/sdk/platform-tools:/Users/LB/.meteor
9 verbose lifecycle uniScore@1.0.0~start: PATH: /usr/local/lib/node_modules/npm/bin/node-gyp-bin:/Users/LB/Desktop/z_Projects/uniScore/node_modules/.bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/go/bin:/usr/local/MacGPG2/bin:/Library/TeX/texbin:/Users/LB/.rvm/bin:/Users/LB/pebble-dev/PebbleSDK-3.6/bin:/usr/local/sbin:/Users/LB/Library/Android/sdk/platform-tools:/Users/LB/.meteor:/Users/LB/.rvm/bin:/Users/LB/pebble-dev/PebbleSDK-3.6/bin:/usr/local/sbin:/Users/LB/Library/Android/sdk/platform-tools:/Users/LB/.meteor
10 verbose lifecycle uniScore@1.0.0~start: CWD: /Users/LB/Desktop/z_Projects/uniScore
11 silly lifecycle uniScore@1.0.0~start: Args: [ '-c', 'node ./bin/www' ]
12 silly lifecycle uniScore@1.0.0~start: Returned: code: 1 signal: null

View File

@ -7,6 +7,7 @@
<link rel='stylesheet' href='/css/bootstrap.min.css' />
<script type='text/javascript' src='/js/jquery-3.1.1.min.js'></script>
<script type='text/javascript' src='/js/bootstrap.min.js'></script>
<script type='text/javascript' src='/js/front_client.js'></script>
</head>
<body>
<h1>Aktueller Spielstand</h1>