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,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;

+ 2
- 0
web/params.cfg View File

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