|
@@ -363,7 +363,7 @@ public class Controller {
|
363
|
363
|
date = new Date();
|
364
|
364
|
date1.setTime(date);
|
365
|
365
|
dateString=date1.toString();
|
366
|
|
- this.getHistory().saveMessage(getMyUser(), c.getRemoteUser(),message ,dateString );
|
|
366
|
+ //this.getHistory().saveMessage(getMyUser(), c.getRemoteUser(),message ,dateString );
|
367
|
367
|
|
368
|
368
|
/*
|
369
|
369
|
System.out.println(this.getHistory());
|
|
@@ -378,7 +378,7 @@ public class Controller {
|
378
|
378
|
//this.getHistory().saveMessage(this.myUser, c.getRemoteUser(),message ,dateString);
|
379
|
379
|
|
380
|
380
|
// Envoie du message (avec la date)
|
381
|
|
- //DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
|
|
381
|
+ DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
|
382
|
382
|
out.println(dateString);
|
383
|
383
|
out.println(message);
|
384
|
384
|
}
|
|
@@ -489,60 +489,70 @@ public class Controller {
|
489
|
489
|
/*************************************************************************************************************************/
|
490
|
490
|
public static void main(String[] args) throws IOException, InterruptedException {
|
491
|
491
|
|
492
|
|
- System.out.println("start program");
|
|
492
|
+ System.out.println("start program");
|
493
|
493
|
|
494
|
|
- Historique histoire=new Historique();
|
495
|
|
-
|
|
494
|
+ Historique histoire=new Historique();
|
|
495
|
+
|
496
|
496
|
|
497
|
|
- /** Création des utilisateurs **/
|
498
|
|
- // REMOTEUSER_1 - MIKE
|
499
|
|
- Controller ctr2 = new Controller(31012,portUDPlistening_remoteUsr2,31022,"Mike",histoire);
|
500
|
|
- // REMOTEUSER_2 - ALICE
|
501
|
|
- Controller ctr3 = new Controller(31013,portUDPlistening_remoteUsr3,31023,"Alice",histoire);
|
502
|
|
- // LOCAL USER
|
503
|
|
- Controller ctr1 = new Controller(31011,31001,31021,histoire);
|
|
497
|
+ /** Création des utilisateurs **/
|
|
498
|
+ // REMOTEUSER_1 - MIKE
|
|
499
|
+ Controller ctr2 = new Controller(31012,portUDPlistening_remoteUsr2,31022,"Mike",histoire);
|
|
500
|
+ // REMOTEUSER_2 - ALICE
|
|
501
|
+ Controller ctr3 = new Controller(31013,portUDPlistening_remoteUsr3,31023,"Alice",histoire);
|
|
502
|
+ // LOCAL USER
|
|
503
|
+ Controller ctr1 = new Controller(31011,31001,31021,histoire);
|
504
|
504
|
|
505
|
|
- /** Création de l'interface graphique **/
|
506
|
|
- ctr1.hisView=Interface.createAndShowGUI(ctr1);
|
507
|
|
-
|
508
|
|
- /** Simulation of a session **/
|
509
|
|
- // SELECT REMOTE USER
|
510
|
|
- Chat chatwithrm0 = ctr1.myUser.addChats(ctr1.myUser.getRemoteUsersList().get(0));
|
511
|
|
- // AFFICHAGE REMOTE USER CHOISIE
|
512
|
|
- System.out.println("("+ctr1.myUser.getPseudo()+" ) OPEN SESSION WITH "+ctr1.myUser.getRemoteUsersList().get(0).getPseudo());
|
513
|
|
- // OPEN SESSION
|
514
|
|
- ctr1.openSession(chatwithrm0);
|
515
|
|
- // SEND MESSAGE
|
516
|
|
- ctr1.sendMsg(new Msg_Text(ctr1.myUser.getAddIP(),"test"), chatwithrm0);
|
517
|
|
- // CLOSE SESSION
|
518
|
|
- ctr1.sendMsg(new Msg_Text(ctr1.myUser.getAddIP(),"end"), chatwithrm0);
|
519
|
|
- ctr1.closeSession(chatwithrm0);
|
|
505
|
+ /** Création de l'interface graphique **/
|
|
506
|
+ Boolean interfaceRunning = true;
|
|
507
|
+ ctr1.hisView=Interface.createAndShowGUI(ctr1);
|
|
508
|
+
|
|
509
|
+ /** Simulation of a session **/
|
|
510
|
+
|
|
511
|
+ // SELECT REMOTE USER
|
|
512
|
+ Chat chatwithrm0 = ctr1.myUser.addChats(ctr1.myUser.getRemoteUsersList().get(0));
|
|
513
|
+ // AFFICHAGE REMOTE USER CHOISIE
|
|
514
|
+ System.out.println("("+ctr1.myUser.getPseudo()+" ) OPEN SESSION WITH "+ctr1.myUser.getRemoteUsersList().get(0).getPseudo());
|
|
515
|
+ // OPEN SESSION
|
|
516
|
+ ctr1.openSession(chatwithrm0);
|
|
517
|
+ // SEND MESSAGE
|
|
518
|
+ ctr1.sendMsg(new Msg_Text(ctr1.myUser.getAddIP(),"test"), chatwithrm0);
|
|
519
|
+ // CLOSE SESSION
|
|
520
|
+ ctr1.sendMsg(new Msg_Text(ctr1.myUser.getAddIP(),"end"), chatwithrm0);
|
|
521
|
+ ctr1.closeSession(chatwithrm0);
|
|
522
|
+
|
|
523
|
+
|
|
524
|
+ /** Unused function **/
|
|
525
|
+ // MANUAL SELECTION OF ACTIVE USER
|
|
526
|
+ //ctr1.selectActiveUser();
|
|
527
|
+ // CHANGE USER NICKNAME
|
|
528
|
+ //ctr1.changePseudo();
|
|
529
|
+
|
|
530
|
+
|
|
531
|
+ /*
|
|
532
|
+ while(interfaceRunning) {
|
520
|
533
|
|
521
|
|
- /** Unused function **/
|
522
|
|
- // MANUAL SELECTION OF ACTIVE USER
|
523
|
|
- //ctr1.selectActiveUser();
|
524
|
|
- // CHANGE USER NICKNAME
|
525
|
|
- //ctr1.changePseudo();
|
526
|
|
-
|
527
|
|
- /** Close thread and socket **/
|
528
|
|
- // SLEEP 5 SEC
|
529
|
|
- System.out.println("Sleep mode for 5 seconds ...");
|
530
|
|
- Thread.sleep(5000);
|
531
|
|
- // REMOTEUSER_1 - MIKE
|
532
|
|
- ctr2.myUser.closeAllRemainingChatSocket();
|
533
|
|
- ctr2.tcp_connect_thread.close();
|
534
|
|
- ctr2.udp_connect_thread.close();
|
535
|
|
- // REMOTEUSER_2 - ALICE
|
536
|
|
- ctr3.myUser.closeAllRemainingChatSocket();
|
537
|
|
- ctr3.tcp_connect_thread.close();
|
538
|
|
- ctr3.udp_connect_thread.close();
|
539
|
|
- // LOCAL USER
|
540
|
|
- ctr1.myUser.closeAllRemainingChatSocket();
|
541
|
|
- ctr1.tcp_connect_thread.close();
|
542
|
|
- ctr1.udp_connect_thread.close();
|
543
|
|
- // AFFICHAGE
|
544
|
|
- System.out.println("end program");
|
545
|
|
- JOptionPane.showMessageDialog(null ,"END");
|
|
534
|
+ }*/
|
|
535
|
+
|
|
536
|
+ /** Close thread and socket **/
|
|
537
|
+ // SLEEP 20 SEC
|
|
538
|
+ System.out.println("Sleep mode for 20 seconds ...");
|
|
539
|
+ Thread.sleep(20000);
|
|
540
|
+
|
|
541
|
+ // REMOTEUSER_1 - MIKE
|
|
542
|
+ ctr2.myUser.closeAllRemainingChatSocket();
|
|
543
|
+ ctr2.tcp_connect_thread.close();
|
|
544
|
+ ctr2.udp_connect_thread.close();
|
|
545
|
+ // REMOTEUSER_2 - ALICE
|
|
546
|
+ ctr3.myUser.closeAllRemainingChatSocket();
|
|
547
|
+ ctr3.tcp_connect_thread.close();
|
|
548
|
+ ctr3.udp_connect_thread.close();
|
|
549
|
+ // LOCAL USER
|
|
550
|
+ ctr1.myUser.closeAllRemainingChatSocket();
|
|
551
|
+ ctr1.tcp_connect_thread.close();
|
|
552
|
+ ctr1.udp_connect_thread.close();
|
|
553
|
+ // AFFICHAGE
|
|
554
|
+ System.out.println("end program");
|
|
555
|
+ JOptionPane.showMessageDialog(null ,"END");
|
546
|
556
|
}
|
547
|
557
|
|
548
|
558
|
}
|