mirror of
https://github.com/klmp200/PQT_Gestionnaire_vente_stock.git
synced 2024-11-22 16:23:20 +00:00
Module Client, clss HttpTextSender : Nettoyage du code; Ajout d'une méthd privée encode(...)
This commit is contained in:
parent
6b7de9a97c
commit
5ba82437bf
@ -13,9 +13,9 @@ import java.net.URLEncoder;
|
|||||||
|
|
||||||
public class HttpTextSender implements ITextSender{
|
public class HttpTextSender implements ITextSender{
|
||||||
@Override
|
@Override
|
||||||
public void send(String url, String text, IConnectionListener listener) {
|
public void send(String host, String text, IConnectionListener listener) {
|
||||||
try {
|
try {
|
||||||
String trueURL = String.format("http://%s?message=%s", url, text);
|
String trueURL = String.format("http://%s?%s", host, encode(text));
|
||||||
|
|
||||||
//TODO remove sysout
|
//TODO remove sysout
|
||||||
{
|
{
|
||||||
@ -31,12 +31,7 @@ public class HttpTextSender implements ITextSender{
|
|||||||
con.setReadTimeout(5000);
|
con.setReadTimeout(5000);
|
||||||
con.setInstanceFollowRedirects(true);
|
con.setInstanceFollowRedirects(true);
|
||||||
|
|
||||||
String params = URLEncoder.encode("message="+text, "UTF-8");
|
|
||||||
con.setDoOutput(true);
|
con.setDoOutput(true);
|
||||||
try(DataOutputStream out = new DataOutputStream(con.getOutputStream())) {
|
|
||||||
out.writeBytes(params);
|
|
||||||
out.flush();
|
|
||||||
}
|
|
||||||
con.connect();
|
con.connect();
|
||||||
listener.onConnectedEvent();
|
listener.onConnectedEvent();
|
||||||
|
|
||||||
@ -67,4 +62,9 @@ public class HttpTextSender implements ITextSender{
|
|||||||
listener.onDisconnectedEvent();
|
listener.onDisconnectedEvent();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Méthode à modifier pour encoder le message suivant un algorithme spécifique
|
||||||
|
private String encode(String toEncode){
|
||||||
|
return toEncode;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user