FIX problème de l'encapsulation de JSON dans de l'xml. jQuery.js a été modifié.....
[euphorik.git] / modules / erl / euphorik_requests.erl
index 42348cf..13a86cb 100755 (executable)
@@ -28,28 +28,18 @@ out(A) ->
 
 \r
 traiter_donnees(Contenu) ->
-   % FIXME : ne plus encapsuler le JSON dans de l'xml... apparement yaws veux absolument de l'xml (voir post mi-avril 2008 sur la mailing list)\r
-   Reponse = case xmerl_scan:string(Contenu) of
-      {#xmlElement{name = json, content = [#xmlText{value = J}|_]}, _} ->
-         case json:decode_string(J) of
-            {ok, {struct, [{action, Action}| Reste]}} ->
-               %io:format("~p~n", [euphorik_protocole:login(JSON)]),
-               json:encode(traiter_action(Action, Reste));
-            _ ->
-               error
-         end;
-      _ -> error
-   end,
-   if Reponse =:= error ->
-         euphorik_protocole:erreur("Format XML/JSON incorrect");
-      true ->
-         Reponse
+   case json:decode_string(Contenu) of
+      {ok, {struct, [{action, Action}| Reste]}} ->
+         %io:format("~p~n", [euphorik_protocole:login(JSON)]),
+         json:encode(traiter_action(Action, Reste));
+      _ ->
+         error
    end.
    
 
 % authentification d'un client
 traiter_action("authentification", JSON) ->
-   euphorik_protocole:login(JSON));
+   euphorik_protocole:login(JSON);
 % un client s'enregistre (pseudo + password)
 traiter_action("register", JSON) ->
    euphorik_protocole:register(JSON);
@@ -61,20 +51,5 @@ traiter_action("wait_event", JSON) ->
    euphorik_protocole:wait_event(JSON);
 % un utilisateur envoie un message
 traiter_action("put_message", JSON) ->
-   euphorik_protocole:message(JSON).\r
-
-
-
-
-traiter_action([#xmlAttribute{value="register"}], XML) ->
-   euphorik_protocole:nouveau_user_login(XML); 
-traiter_action([#xmlAttribute{value="login"}], XML) ->
-   euphorik_protocole:login(XML); 
-traiter_action([#xmlAttribute{value="profile"}], XML) ->
-   euphorik_protocole:profile(XML); 
-traiter_action([#xmlAttribute{value="refreshMessages"}], XML) ->
- euphorik_protocole:refreshMessage(XML); 
-% un utilisateur envoie un message
-traiter_action([#xmlAttribute{value="message"}], XML) ->
-   euphorik_protocole:message(XML).
+   euphorik_protocole:put_message(JSON).
  
\ No newline at end of file