2016-02-14 00:49:19 +11:00
|
|
|
/**
|
2016-02-14 01:01:43 +11:00
|
|
|
* @file npg_app.js
|
2016-02-14 00:49:19 +11:00
|
|
|
* @author frtk
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2016-02-14 01:01:43 +11:00
|
|
|
/**
|
2016-02-14 00:49:19 +11:00
|
|
|
* nodejs modules
|
|
|
|
*/
|
|
|
|
//---
|
|
|
|
var fs = require('fs');
|
|
|
|
var express = require('express');
|
|
|
|
var http = require('http');
|
|
|
|
|
|
|
|
|
2016-02-14 01:01:43 +11:00
|
|
|
/**
|
|
|
|
* npg server
|
|
|
|
*/
|
|
|
|
//---
|
|
|
|
var cfg = require('./server/npg_server_config.js');
|
|
|
|
var npg = require('./server/npg_server.js');
|
2016-02-14 00:49:19 +11:00
|
|
|
npg.NPGServer.init(cfg.Config);
|
|
|
|
|
|
|
|
|
2016-02-14 01:01:43 +11:00
|
|
|
/**
|
|
|
|
* HTTP
|
2016-02-14 00:49:19 +11:00
|
|
|
*/
|
|
|
|
//--- HTTP server
|
|
|
|
npg.NPGServer.log("$ # starting http service on port " + npg.NPGServer.port);
|
|
|
|
var app = express();
|
|
|
|
var httpserv = http.createServer(app);
|
|
|
|
httpserv.listen(npg.NPGServer.port);
|
|
|
|
//--- allow access to static files from "/client" directory
|
|
|
|
app.use(express.static(__dirname + '/client/'));
|
|
|
|
|
2016-02-14 01:01:43 +11:00
|
|
|
|
|
|
|
/**
|
|
|
|
* socket.io
|
|
|
|
*/
|
2016-02-14 00:49:19 +11:00
|
|
|
//--- socket.io
|
|
|
|
npg.NPGServer.log('$ # registering socket.io service on port ' + npg.NPGServer.port);
|
|
|
|
var io = require('socket.io').listen(httpserv, { log: true } );
|
|
|
|
//-- setup server socket handling features
|
|
|
|
npg.NPGServer.socketHandling(io);
|
|
|
|
npg.NPGServer.log('$ #####');
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-02-14 01:01:43 +11:00
|
|
|
/**
|
|
|
|
* run app
|
2016-02-14 00:49:19 +11:00
|
|
|
*/
|
|
|
|
//---
|
|
|
|
|