added config setup

This commit is contained in:
2015-09-15 14:01:51 +01:00
parent 9c4bfb9e2b
commit 38bf0fe541
3 changed files with 15 additions and 5 deletions

3
.gitignore vendored
View File

@@ -25,3 +25,6 @@ build/Release
# Dependency directory # Dependency directory
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git # https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
node_modules node_modules
# config file
config.js

11
chat.js
View File

@@ -1,7 +1,8 @@
// Load the TCP Library // Load the TCP Library
net = require('net'); var net = require('net'),
clc = require('cli-color'); clc = require('cli-color'),
moment = require('moment'); moment = require('moment'),
config = require('./config');
// Keep track of the chat clients // Keep track of the chat clients
var clients = []; var clients = [];
@@ -106,7 +107,7 @@ net.createServer(function (socket) {
socket.on('end', function () { socket.on('end', function () {
clientService.removeUser(socket); clientService.removeUser(socket);
}); });
}).listen(5000); }).listen(config.server.port);
// Put a friendly message on the terminal of the server. // Put a friendly message on the terminal of the server.
console.log("Chat server running at port 5000"); console.log("Chat server running at port " + config.server.port);

6
config.example.js Normal file
View File

@@ -0,0 +1,6 @@
var config = {};
config.server = {};
config.server.port ='5000';
module.exports = config;