|
@@ -1,5 +1,22 @@
|
1
|
1
|
var io = require('socket.io'); // Chargement du module pour mettre en place les websockets
|
2
|
2
|
var http = require('http');
|
|
3
|
+var fs = require('fs'), cfgFilePath = '';
|
|
4
|
+var httpHost = 'localhost', httpPath = '/burger-quizz/web/api/';
|
|
5
|
+
|
|
6
|
+// Lecture du fichier de configuration
|
|
7
|
+if(process.argv.length > 2) {
|
|
8
|
+ cfgFilePath = process.argv[2];
|
|
9
|
+} else {
|
|
10
|
+ cfgFilePath = '../../params.cfg';
|
|
11
|
+}
|
|
12
|
+
|
|
13
|
+var params = fs.readFileSync(cfgFilePath).toString();
|
|
14
|
+
|
|
15
|
+var httpHost = params.match(/http_host: (.+)/)[0];
|
|
16
|
+var httpPath = params.match(/http_path: (.+)/)[0];
|
|
17
|
+
|
|
18
|
+console.log("Serveur initialisé sur l'URL "+httpHost+httpPath);
|
|
19
|
+
|
3
|
20
|
var json;
|
4
|
21
|
// Variables
|
5
|
22
|
var server; // Le socket
|
|
@@ -42,7 +59,7 @@ function onSocketConnection(client) {
|
42
|
59
|
console.log(err);
|
43
|
60
|
});
|
44
|
61
|
client.on('start', function(gameID) {
|
45
|
|
- http.get("http://localhost/burger-quizz/web/api/", function(res) {
|
|
62
|
+ http.get("http://"+httpHost+httpPath"/api/", function(res) {
|
46
|
63
|
var data = "";
|
47
|
64
|
res.on("data", function(returned) {
|
48
|
65
|
data += returned;
|