Phase de Test sur l'historique
This commit is contained in:
parent
616067cd20
commit
41be85aebe
6 changed files with 24 additions and 5 deletions
Binary file not shown.
|
@ -53,7 +53,7 @@ public class Historique {
|
|||
n = HistoriqueHorodate.size();
|
||||
}
|
||||
for(int i = 0; i<n;i++) {
|
||||
String exp = HistoriqueHorodate.get(i).getSource().toString();
|
||||
String exp = HistoriqueHorodate.get(i).getSource().getPseudo();
|
||||
String payload = HistoriqueHorodate.get(i).getMessage();
|
||||
System.out.println(exp+" : "+payload);
|
||||
}
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -36,6 +36,7 @@ public class TCPEchange {
|
|||
System.out.println("Un thread s'est arrete brusquement");
|
||||
}
|
||||
System.out.println("Tout s'est passé crème");
|
||||
app.getHist(User2.getPseudo()).afficher10derniers();
|
||||
|
||||
}
|
||||
|
||||
|
@ -125,6 +126,10 @@ class RunnerTCPEnvoi implements Runnable {
|
|||
out.flush();
|
||||
break;
|
||||
}
|
||||
Historique h = app.getHist(Destinataire.getPseudo());
|
||||
h.addMessage(mh);
|
||||
// on update la liste des historiques de app
|
||||
app.majHistorique(Destinataire.getPseudo(), h);
|
||||
|
||||
out.println(mh);
|
||||
System.out.println("Envoi d'un mesage");
|
||||
|
@ -146,9 +151,11 @@ class RunnerTCPEcoute implements Runnable {
|
|||
final Socket link;
|
||||
private ChatApp app ;
|
||||
private Utilisateur u2;
|
||||
private boolean u2Initialise;
|
||||
public RunnerTCPEcoute(Socket link,ChatApp app ) {
|
||||
this.link = link;
|
||||
this.app = app;
|
||||
this.u2Initialise=false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -166,22 +173,24 @@ class RunnerTCPEcoute implements Runnable {
|
|||
String date = "";
|
||||
String payload = "";
|
||||
String msg = "";
|
||||
line = in.readLine();
|
||||
while (line != null) {
|
||||
|
||||
line = in.readLine();
|
||||
|
||||
if(line.split(":")[0].equals("Destinataire")) {
|
||||
if(msg.equals("")) {
|
||||
dest = line+"\n";
|
||||
msg=".";
|
||||
}
|
||||
else {
|
||||
msg=dest+src+type+date+payload;
|
||||
payload = "";
|
||||
MessageHorodate mh = MessageHorodate.stringToMessageHorodate(msg);
|
||||
System.out.println("Type du message:"+mh.getType());
|
||||
if(mh.getType()==1) {
|
||||
System.out.println("Historique mis à jour lors de la reception");
|
||||
Historique h = app.getHist(mh.getSource().getPseudo());
|
||||
h.addMessage(mh);
|
||||
|
||||
app.majHistorique(mh.getSource().getPseudo(), h);
|
||||
}
|
||||
else if(mh.getType()==0) {
|
||||
|
@ -192,15 +201,21 @@ class RunnerTCPEcoute implements Runnable {
|
|||
}
|
||||
else if(line.split(":")[0].equals("Source")) {
|
||||
src = line+"\n";
|
||||
if(!u2Initialise) {
|
||||
u2=Utilisateur.stringToUtilisateur(src.split(":")[1].replaceAll("\n", ""));
|
||||
System.out.println("u2Initialise !");
|
||||
u2Initialise = true;
|
||||
}
|
||||
}
|
||||
else if(line.split(":")[0].equals("Type")) {
|
||||
if(line.split(":")[1].equals("2")) {
|
||||
System.out.println("Bonjour recu!");
|
||||
//System.out.println(src.split(":")[1].replaceAll("\n", ""));
|
||||
u2=Utilisateur.stringToUtilisateur(src.split(":")[1].replaceAll("\n", ""));
|
||||
u2Initialise = true;
|
||||
System.out.println("Pseudo du poto: >>"+u2.getPseudo()+"<<");
|
||||
Thread t = new Thread(new RunnerTCPEnvoi(link,app,u2,true));
|
||||
t.start();
|
||||
|
||||
System.out.println("Thread d'envoi envoye");
|
||||
}
|
||||
type = line+"\n";
|
||||
|
@ -213,10 +228,13 @@ class RunnerTCPEcoute implements Runnable {
|
|||
}
|
||||
|
||||
System.out.println("Received: "+ line);
|
||||
|
||||
line = in.readLine();
|
||||
|
||||
|
||||
}
|
||||
System.out.println("Affichage de l'histo");
|
||||
System.out.println("Pseudo du poto: >>"+u2.getPseudo()+"<<");
|
||||
app.getHist(u2.getPseudo()).afficher10derniers();
|
||||
in.close();
|
||||
link.close();
|
||||
} catch (IOException e) {
|
||||
|
@ -224,6 +242,7 @@ class RunnerTCPEcoute implements Runnable {
|
|||
} finally {
|
||||
System.out.println("Finishing thread");
|
||||
System.out.println("Affichage de l'histo");
|
||||
System.out.println("Pseudo du poto: >>"+u2.getPseudo()+"<<");
|
||||
app.getHist(u2.getPseudo()).afficher10derniers();
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue