Petits ajustements
Remplacement des \n par System.lineseparator et utilisation de stringbuilder pour la récupération de l'historique.
This commit is contained in:
parent
79ee62e6d8
commit
031da499e1
10 changed files with 27 additions and 27 deletions
|
@ -6,7 +6,7 @@
|
|||
<attribute name="module" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="lib" path="C:/Program Files/Java/mysql-connector-java-8.0.22.jar">
|
||||
<classpathentry kind="lib" path="C:/Program Files/Java/mysql-connector-java-8.0.22.jar" sourcepath="C:/Users/Marin/.m2/repository/mysql/mysql-connector-java/8.0.22/mysql-connector-java-8.0.22-sources.jar">
|
||||
<attributes>
|
||||
<attribute name="module" value="true"/>
|
||||
</attributes>
|
||||
|
|
|
@ -50,7 +50,7 @@ public class GestionnaireHistorique {
|
|||
int rs1;
|
||||
ResultSet rs2 = null;
|
||||
Connection con = null;
|
||||
String history = "";
|
||||
StringBuilder history = new StringBuilder();
|
||||
|
||||
String query1 =
|
||||
"CREATE TABLE IF NOT EXISTS " + id
|
||||
|
@ -75,8 +75,8 @@ public class GestionnaireHistorique {
|
|||
|
||||
while(rs2.next()) {
|
||||
System.out.println("Historic SUCCESS");
|
||||
history += GestionnaireNom.instance().nomFromId(rs2.getString(2)) + ": "; //indice commence à 1
|
||||
history += rs2.getString(3) + "\n";
|
||||
history.append(GestionnaireNom.instance().nomFromId(rs2.getString(2)) + ": "); //indice commence à 1
|
||||
history.append(rs2.getString(3) + System.lineSeparator());
|
||||
}
|
||||
|
||||
// à mettre dans un finally
|
||||
|
@ -91,7 +91,7 @@ public class GestionnaireHistorique {
|
|||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return history;
|
||||
return history.toString();
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ public class GestionnaireSessionsLocales implements Runnable{
|
|||
TCPClient client = new TCPClient(gn.ipFromNom(name), PORT_REQUETE_NOUVELLE_SESSION + Integer.parseInt(gn.idFromNom(name))) ;
|
||||
SessionClavardageLocale session = new SessionClavardageLocale(gn.getId(), gn.idFromNom(name), client, null);
|
||||
this.sessions.put(gn.idFromNom(name), session);
|
||||
client.send(gn.getId()+"\n");
|
||||
client.send(gn.getId()+System.lineSeparator());
|
||||
System.out.print("Paramètres de session envoyée à " + gn.idFromNom(name) + "\n");
|
||||
|
||||
//Lancement de la fenêtre de session
|
||||
|
@ -102,7 +102,7 @@ public class GestionnaireSessionsLocales implements Runnable{
|
|||
TCPClient clientEnvoi = new TCPClient(client.getAdresseCible(), PORT_REQUETE_NOUVELLE_SESSION + Integer.parseInt(idClient));
|
||||
SessionClavardageLocale session = new SessionClavardageLocale(gn.getId(), idClient, clientEnvoi, client);
|
||||
this.sessions.put(idClient, session);
|
||||
clientEnvoi.send(gn.getId()+"\n");
|
||||
clientEnvoi.send(gn.getId()+System.lineSeparator());
|
||||
System.out.print("Fin de la configuration de " + gn.getId() + "\n");
|
||||
System.out.println("Il y a actuellement " + sessions.size() + " session(s) ouverte(s).");
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ public abstract class SessionClavardage {
|
|||
|
||||
|
||||
public String toString() {
|
||||
return "Session entre " + "this.idSource" + " et " + this.idDestination + "\n";
|
||||
return "Session entre " + "this.idSource" + " et " + this.idDestination + System.lineSeparator();
|
||||
}
|
||||
|
||||
public String getIdSource() {
|
||||
|
|
|
@ -61,7 +61,7 @@ public class SessionClavardageDistante extends SessionClavardage{
|
|||
}
|
||||
|
||||
public String toString() {
|
||||
return "Session à distance entre " + this.getIdSource() + " et " + this.getIdDestination() + "\n";
|
||||
return "Session à distance entre " + this.getIdSource() + " et " + this.getIdDestination() + System.lineSeparator();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ public class SessionClavardageLocale extends SessionClavardage{
|
|||
@Override
|
||||
public String toString() {
|
||||
return "Session locale entre " + this.idSource + " à l'adresse " + this.clientEmission.getAdresseSource()
|
||||
+ ", et " + this.idDestination + " à l'adresse " + this.clientEmission.getAdresseCible() + "\n";
|
||||
+ ", et " + this.idDestination + " à l'adresse " + this.clientEmission.getAdresseCible() + System.lineSeparator();
|
||||
}
|
||||
|
||||
public TCPClient getClientReception() {
|
||||
|
|
|
@ -23,7 +23,7 @@ public class ServletResponse {
|
|||
|
||||
public String toString (){
|
||||
if (this.messageList != null) {
|
||||
return "Status code: " + this.statusCode +", " + this.messageList.size() + " messages reçus.";
|
||||
return "Status code: " + this.statusCode +", " + this.messageList.size() + " messages reçus.";
|
||||
}
|
||||
else {
|
||||
return "Status code: " + this.statusCode;
|
||||
|
|
|
@ -17,7 +17,7 @@ public class Main {
|
|||
//on lance le server d'écoute de cmd
|
||||
GestionnaireListeUtilisateur.instance().ecoute2(2001);
|
||||
|
||||
//on crée manuellement des utilisateurs //debug
|
||||
//on crée manuellement des utilisateurs //debug1
|
||||
GestionnaireListeUtilisateur.instance().envoie2("add$$$77$$$Moidebug$$$LocalHost$$$true");
|
||||
|
||||
//on met à jour notre liste
|
||||
|
|
|
@ -36,12 +36,12 @@ public class TCPClient {
|
|||
this.socket = new Socket(host, port);
|
||||
}
|
||||
catch (UnknownHostException e) {
|
||||
System.out.print("Could not find host\n");
|
||||
System.out.println("Could not find host");
|
||||
}
|
||||
catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
System.out.print("port= "+port+" host= "+host+"\n");
|
||||
System.out.print("Could not create socket\n");
|
||||
System.out.println("port= "+port+" host= "+host);
|
||||
System.out.println("Could not create socket");
|
||||
}
|
||||
|
||||
|
||||
|
@ -51,13 +51,13 @@ public class TCPClient {
|
|||
this.textInput = new BufferedReader(new InputStreamReader(socket.getInputStream()));
|
||||
}
|
||||
catch (IOException e) {
|
||||
System.out.print("Error while reading textInput stream\n");
|
||||
System.out.println("Error while reading textInput stream");
|
||||
}
|
||||
try {
|
||||
this.textOutput = new PrintWriter(socket.getOutputStream(),true);
|
||||
}
|
||||
catch (IOException e) {
|
||||
System.out.print("Error while reading textOutput stream\n");
|
||||
System.out.println("Error while reading textOutput stream");
|
||||
}
|
||||
this.support = new PropertyChangeSupport(this);
|
||||
|
||||
|
@ -72,13 +72,13 @@ public class TCPClient {
|
|||
this.textInput = new BufferedReader(new InputStreamReader(socket.getInputStream()));
|
||||
}
|
||||
catch (IOException e) {
|
||||
System.out.print("Error while reading textInput stream");
|
||||
System.out.println("Error while reading textInput stream");
|
||||
}
|
||||
try {
|
||||
this.textOutput = new PrintWriter(socket.getOutputStream(),true);
|
||||
}
|
||||
catch (IOException e) {
|
||||
System.out.print("Error while reading textOutput stream");
|
||||
System.out.println("Error while reading textOutput stream");
|
||||
}
|
||||
support = new PropertyChangeSupport(this);
|
||||
}
|
||||
|
@ -115,7 +115,7 @@ public class TCPClient {
|
|||
this.socket.close();
|
||||
}
|
||||
catch (IOException e) {
|
||||
System.out.print("Error while closing connection\n");
|
||||
System.out.println("Error while closing connection");
|
||||
}
|
||||
|
||||
|
||||
|
@ -128,7 +128,7 @@ public class TCPClient {
|
|||
this.socket = new Socket(this.adresseCible.getHostName(), port);
|
||||
}
|
||||
catch (UnknownHostException e) {
|
||||
System.out.print("Could not find host");
|
||||
System.out.println("Could not find host");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -155,10 +155,10 @@ public class TCPClient {
|
|||
public static void main(String[] args) throws IOException{
|
||||
//TCPClient client = new TCPClient("LAPTOP-944OJJB9", 19999);
|
||||
TCPClient client = new TCPClient("srv-gei-tomcat.insa-toulouse.fr", 19999);
|
||||
String message = "Bonjour.\n";
|
||||
String message = "Bonjour.";
|
||||
System.out.printf("Message envoyé: %s", message);
|
||||
client.send(message);
|
||||
System.out.printf("Message reçu: %s\n", client.receive());
|
||||
System.out.printf("Message reçu: %s"+System.lineSeparator(), client.receive());
|
||||
client.stop();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,14 +54,14 @@ public class DiscussionUI extends JFrame implements PropertyChangeListener{
|
|||
ArrayList <Message> list = session.getNewMessages();
|
||||
for (Message msg : list) {
|
||||
if (msg.getType().equals("command") && msg.getBody().equals("stopSession")) {
|
||||
historicField.setText(historicField.getText() + GestionnaireNom.instance().nomFromId(session.getIdDestination()) + " s'est déconnecté(e).\n");
|
||||
historicField.setText(historicField.getText() + GestionnaireNom.instance().nomFromId(session.getIdDestination()) + " s'est déconnecté(e)."+System.lineSeparator());
|
||||
this.finDeSession();
|
||||
}
|
||||
else
|
||||
{
|
||||
System.out.print(msg);
|
||||
String message = GestionnaireNom.instance().nomFromId(msg.getSender()) + ": " + msg.getBody();
|
||||
historicField.setText(historicField.getText() + message + "\n");
|
||||
historicField.setText(historicField.getText() + message + System.lineSeparator());
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -83,8 +83,8 @@ public class DiscussionUI extends JFrame implements PropertyChangeListener{
|
|||
message.setSender(this.session.getIdSource());
|
||||
message.setRecipient(this.session.getIdDestination());
|
||||
textField.setText("");
|
||||
historicField.append(GestionnaireNom.instance().nomFromId(message.getSender()) +": " + message.getBody() + "\n");
|
||||
//session.send(GestionnaireNom.instance().nomFromId(session.getIdSource()) + ": " + message+"\n");
|
||||
historicField.append(GestionnaireNom.instance().nomFromId(message.getSender()) +": " + message.getBody() + System.lineSeparator());
|
||||
//session.send(GestionnaireNom.instance().nomFromId(session.getIdSource()) + ": " + message+System.lineSeparator());
|
||||
try {
|
||||
session.sendObject(message);
|
||||
} catch (IOException e) {
|
||||
|
|
Loading…
Reference in a new issue