MOD avancement dans le module 'communication'
[euphorik.git] / js / client.js
index 11466a9..93e5dae 100644 (file)
@@ -21,8 +21,9 @@
 /**\r
   * Représente l'utilisateur du site.\r
   */\r
-euphorik.Client = function(util) {\r
+euphorik.Client = function(util, communication) {\r
    this.util = util;\r
+   this.communication = communication\r
    \r
    this.cookie = null;\r
    this.regexCookie = /^cookie=([^;]*)/;\r
@@ -314,25 +315,20 @@ euphorik.Client.prototype.enregistrement = function(login, password) {
 /**\r
   * Connexion. Réalisée de manière synchrone.\r
   */\r
-euphorik.Client.prototype.connexion = function(messageJson) {\r
+euphorik.Client.prototype.connexion = function(action, messageJson) {\r
    var thisClient = this;\r
-   jQuery.ajax({\r
-      async: false,\r
-      type: "POST",\r
-      url: "request",\r
-      dataType: "json",\r
-      data: this.util.jsonVersAction(messageJson),\r
-      success:\r
-         function(data){\r
-            if (data.reply === "error") {\r
-               thisClient.util.messageDialogue(data.error_message);\r
-               // suppression du cookie actuel, cas où le cookie du client ne permet pas une authentification\r
-               thisClient.delCookie();\r
-            } else {\r
-               thisClient.chargerDonnees(data);\r
-            }\r
-         }\r
-   });\r
+   \r
+   this.communication.requete(\r
+      action,\r
+      messageJson,\r
+      function(data) {\r
+         thisClient.chargerDonnees(data);\r
+      },\r
+      function() {\r
+         thisClient.util.messageDialogue(data.error_message);\r
+         thisClient.delCookie(); // suppression du cookie actuel, cas où le cookie du client ne permet pas une authentification\r
+      }\r
+   );\r
    return this.authentifie();\r
 };\r
 \r