Browse Source

Bugfixing

Brendan Abolivier 9 years ago
parent
commit
085ce3c8b9
2 changed files with 20 additions and 1 deletions
  1. 18
    1
      web/multi/server/server.js
  2. 2
    0
      web/params.cfg

+ 18
- 1
web/multi/server/server.js View File

1
 var io = require('socket.io'); // Chargement du module pour mettre en place les websockets
1
 var io = require('socket.io'); // Chargement du module pour mettre en place les websockets
2
 var http = require('http');
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
 var json;
20
 var json;
4
 // Variables
21
 // Variables
5
 var server; // Le socket
22
 var server; // Le socket
42
       console.log(err);
59
       console.log(err);
43
     });
60
     });
44
     client.on('start', function(gameID) {
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
         var data = "";
63
         var data = "";
47
         res.on("data", function(returned) {
64
         res.on("data", function(returned) {
48
           data += returned;
65
           data += returned;

+ 2
- 0
web/params.cfg View File

1
+http_host: localhost
2
+http_path: /burger-quizz/web/api/
1
 node_host: localhost
3
 node_host: localhost
2
 db_host: localhost
4
 db_host: localhost
3
 db_dbname: burgerquizz
5
 db_dbname: burgerquizz