ADD ajout du bannissement (pas fini)
[euphorik.git] / modules / erl / euphorik_requests.erl
index 6562e52..4af2f7e 100755 (executable)
@@ -20,10 +20,14 @@ tester() ->
 
 \r
 out(A) ->
-   %io:format("~p~n~n", [A]),\r
+   %io:format("~p~n~n", [A]),
+   IP = case inet:peername(A#arg.clisock) of
+         {ok, {Adresse, _Port}} -> Adresse;
+      _ -> inconnue
+   end,\r
    %inet:setopts(A#arg.clisock, inet:getopts(A#arg.clisock, [active])),\r
    {value, {_, Contenu}} = lists:keysearch("action", 1, yaws_api:parse_post(A)),\r
-   Ret = traiter_donnees(Contenu, 1),
+   Ret = traiter_donnees(Contenu, IP),
    {content, "application/json", Ret}.\r
 
 \r
@@ -37,8 +41,8 @@ traiter_donnees(Contenu, IP) ->
    
 
 % authentification d'un client
-traiter_action("authentification", JSON, _) ->
-   euphorik_protocole:login(JSON);
+traiter_action("authentification", JSON, IP) ->
+   euphorik_protocole:login(JSON, IP);
 % un client s'enregistre (pseudo + password)
 traiter_action("register", JSON, IP) ->
    euphorik_protocole:register(JSON, IP);
@@ -50,5 +54,7 @@ traiter_action("wait_event", JSON, _) ->
    euphorik_protocole:wait_event(JSON);
 % un utilisateur envoie un message
 traiter_action("put_message", JSON, _) ->
-   euphorik_protocole:put_message(JSON).
+   euphorik_protocole:put_message(JSON);
+traiter_action("ban", JSON, _) ->
+   euphorik_protocole:ban(JSON).
  
\ No newline at end of file