59 lines
1.2 KiB
JavaScript
59 lines
1.2 KiB
JavaScript
/**
|
|
* @file nodePong.js
|
|
* @author frtk
|
|
*/
|
|
|
|
|
|
/*
|
|
* nodejs modules
|
|
*/
|
|
//---
|
|
var fs = require('fs');
|
|
var colors = require('colors');
|
|
var express = require('express');
|
|
var http = require('http');
|
|
var iosocket = require('socket.io');
|
|
//--- server app libs & params
|
|
var servU = require('./server/server_utils.js');
|
|
var servP = require('./server/server_params.js');
|
|
|
|
|
|
/*
|
|
* starting HTTP and socket.io services
|
|
*/
|
|
//---
|
|
serverMsg("$ ##### nodePong - v0.0.1 ");
|
|
|
|
//--- HTTP server
|
|
serverMsg("$ # starting http service on port " + servP.params.port);
|
|
var app = express();
|
|
var httpserv = http.createServer(app);
|
|
httpserv.listen(servP.params.port);
|
|
//--- allow access to static files from "/client" directory
|
|
app.use(express.static(__dirname + '/client/'));
|
|
|
|
//--- socket.io
|
|
serverMsg('$ # registering socket.io service on port ' + servP.params.port);
|
|
var io = require('socket.io').listen(httpserv, {log: false});
|
|
|
|
serverMsg('$ #####');
|
|
|
|
|
|
|
|
|
|
/*
|
|
* running nodePong server
|
|
*/
|
|
//---
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
* FUNCTIONS
|
|
*/
|
|
function serverMsg(msg) {
|
|
return console.log((servU.datelib.newDateToString() + msg).yellow);
|
|
}
|