-traiter_xml(Contenu) ->\r
- {XML, _} = xmerl_scan:string(Contenu),\r
- traiter_action(XML#xmlElement.attributes, XML).\r
-
-
-% un client demande la génération d'un captcha (obsolète)
-%~ traiter_action([#xmlAttribute{value="generationCaptcha"}], XML) ->
- %~ euphorik_protocole:generation_captcha(XML); \r
-% un client se log pour la première fois (obsolète)\r
-%~ traiter_action([#xmlAttribute{value="loginCaptcha"}], XML) ->\r
- %~ euphorik_protocole:nouveau_user_captcha(XML); \r
- \r
-
+traiter_donnees(Contenu) ->\r
+ case xmerl_scan:string(Contenu) of
+ {XML, _} ->
+ case XML of
+ #xmlElement{name = json, content = [#xmlText{value = J}|_]} ->
+ case json:decode_string(J) of
+ {ok, {struct, [{action, Action}| Reste]}} ->
+ traiter_action(Action, Reste);
+ _ ->
+ erreur
+ end;
+ _ ->
+ traiter_action(XML#xmlElement.attributes, XML)
+ end;
+ _ -> erreur
+ end.\r
+
+
+traiter_action("authentification", JSON) ->
+ euphorik_protocole:login(JSON);