|
@@ -1,467 +0,0 @@
|
1
|
|
-import java.awt.BorderLayout;
|
2
|
|
-import java.awt.Component;
|
3
|
|
-import java.awt.GridLayout;
|
4
|
|
-import java.awt.event.ActionEvent;
|
5
|
|
-import java.awt.event.ActionListener;
|
6
|
|
-import java.io.BufferedReader;
|
7
|
|
-import java.io.IOException;
|
8
|
|
-import java.io.InputStreamReader;
|
9
|
|
-import java.io.PrintWriter;
|
10
|
|
-import java.net.*;
|
11
|
|
-import java.text.DateFormat;
|
12
|
|
-import java.text.SimpleDateFormat;
|
13
|
|
-import java.util.Date;
|
14
|
|
-import javax.swing.JOptionPane;
|
15
|
|
-
|
16
|
|
-import java.util.ArrayList; // import the ArrayList class
|
17
|
|
-
|
18
|
|
-
|
19
|
|
-public class User{
|
20
|
|
-
|
21
|
|
- /*** CONSTANTES ***/
|
22
|
|
- final static int portUDPlistening_remoteUsr2 = 20002; // TO REMOVE when we use broadcast
|
23
|
|
- final static int portUDPlistening_remoteUsr3 = 20003; // TO REMOVE when we use broadcast
|
24
|
|
-
|
25
|
|
- /*** VARIABLES ***/
|
26
|
|
- protected InetAddress addIP;
|
27
|
|
- protected String pseudo;
|
28
|
|
- protected int portUDPsend;
|
29
|
|
- protected int portUDPlistening;
|
30
|
|
- protected int portTCP;
|
31
|
|
- protected boolean actif;
|
32
|
|
-
|
33
|
|
- protected ArrayList<RemoteUser> remoteUserList = new ArrayList<RemoteUser>(); // listes des utilisateurs actifs
|
34
|
|
- protected ArrayList<RemoteUser> userChatList = new ArrayList<RemoteUser>(); // listes des utilisateurs avec qui un chat est actif
|
35
|
|
-
|
36
|
|
- protected UserListeningThreadUDP threadListeningUDP; // UDP listening thread (pour répondre aux nouveaux utilisateurs)
|
37
|
|
- protected UserListeningThreadTCP threadListeningTCP; // TCP listening thread (pour commencer une nouvelle conversation)
|
38
|
|
-
|
39
|
|
- /**
|
40
|
|
- * Constructor of User (local)
|
41
|
|
- * $parametres
|
42
|
|
- * * portUDPsend : int => le numéro de port pour envoyé ces informations lors d'un changements ou d'une nouvelle connexion
|
43
|
|
- * * portUDPlistening : int => le numéro de port pour recevoir les informations des nouveaux utilisateurs ou les changements
|
44
|
|
- * * portTCP : int => le numéro de port pour commencer une nouvelle conversation
|
45
|
|
- * <p>
|
46
|
|
- * On récupère l'adresse de la machine, le numéro de port à utiliser, on demande un pseudo à l'utilisateur
|
47
|
|
- * que l'on vérifie, une fois validé, l'utilisateur devient actif (Début de l'écoute UDP pour les pseudos et notification aux autres utilisateurs actifs)
|
48
|
|
- * </p>
|
49
|
|
- */
|
50
|
|
-
|
51
|
|
- public User(int portUDPsend,int portUDPlistening,int portTCP) throws IOException{
|
52
|
|
- try
|
53
|
|
- {
|
54
|
|
- this.addIP = InetAddress.getLocalHost();
|
55
|
|
- }
|
56
|
|
- catch(UnknownHostException e) {
|
57
|
|
- JOptionPane.showMessageDialog(null ,"Could not find local address!");
|
58
|
|
- }
|
59
|
|
-
|
60
|
|
- this.portUDPsend = portUDPsend;
|
61
|
|
- this.portUDPlistening = portUDPlistening;
|
62
|
|
- this.portTCP = portTCP;
|
63
|
|
-
|
64
|
|
- this.initPseudo();
|
65
|
|
-
|
66
|
|
- this.active();
|
67
|
|
- }
|
68
|
|
-
|
69
|
|
- /**
|
70
|
|
- * Constructor of User (simulation of remote user)
|
71
|
|
- * $parametres
|
72
|
|
- * * portUDPsend : int => le numéro de port pour envoyé ces informations lors d'un changements ou d'une nouvelle connexion
|
73
|
|
- * * portUDPlistening : int => le numéro de port pour recevoir les informations des nouveaux utilisateurs ou les changements
|
74
|
|
- * * portTCP : int => le numéro de port pour commencer une nouvelle conversation
|
75
|
|
- * * pseudo : String => le pseudo avec lequel on initie l'utilisateur distant (! pas de vérification)
|
76
|
|
- * <p>
|
77
|
|
- * On récupère l'adresse de la machine, le numéro de port à utiliser, on demande un pseudo à l'utilisateur
|
78
|
|
- * que l'on vérifie, une fois validé, l'utilisateur devient actif (Début de l'écoute UDP pour les pseudos
|
79
|
|
- * et notification aux autres utilisateurs actifs)
|
80
|
|
- * </p>
|
81
|
|
- */
|
82
|
|
- public User(int portUDPsend,int portUDPlistening, int portTCP,String pseudo) {
|
83
|
|
- try
|
84
|
|
- {
|
85
|
|
- this.addIP = InetAddress.getLocalHost();
|
86
|
|
- }
|
87
|
|
- catch(UnknownHostException e) {
|
88
|
|
- JOptionPane.showMessageDialog(null ,"Could not find local address!");
|
89
|
|
- }
|
90
|
|
- this.portUDPsend = portUDPsend;
|
91
|
|
- this.portUDPlistening = portUDPlistening;
|
92
|
|
- this.portTCP = portTCP;
|
93
|
|
- this.pseudo = pseudo;
|
94
|
|
-
|
95
|
|
- this.active();
|
96
|
|
-
|
97
|
|
- }
|
98
|
|
-
|
99
|
|
-
|
100
|
|
- /*** GETTERS ***/
|
101
|
|
- public InetAddress getAddIP() {
|
102
|
|
- return addIP;
|
103
|
|
- }
|
104
|
|
- public String getPseudo() {
|
105
|
|
- return pseudo;
|
106
|
|
- }
|
107
|
|
- public int getPortTCP() {
|
108
|
|
- return portTCP;
|
109
|
|
- }
|
110
|
|
- public int getPortUDPlistening() {
|
111
|
|
- return portUDPlistening;
|
112
|
|
- }
|
113
|
|
- public int getPortUDPsend() {
|
114
|
|
- return portUDPsend;
|
115
|
|
- }
|
116
|
|
- public boolean isActif() {
|
117
|
|
- return actif;
|
118
|
|
- }
|
119
|
|
-
|
120
|
|
- /*** SETTERS ***/
|
121
|
|
- public void setAddIP(InetAddress addIP) {
|
122
|
|
- this.addIP = addIP;
|
123
|
|
- }
|
124
|
|
- public void setPortTCP(int portTCP) {
|
125
|
|
- this.portTCP = portTCP;
|
126
|
|
- }
|
127
|
|
- public void setPortUDPlistening(int portUDPlistening) {
|
128
|
|
- this.portUDPlistening = portUDPlistening;
|
129
|
|
- }
|
130
|
|
- public void setPortUDPsend(int portUDPsend) {
|
131
|
|
- this.portUDPsend = portUDPsend;
|
132
|
|
- }
|
133
|
|
-
|
134
|
|
- /**
|
135
|
|
- * <p>
|
136
|
|
- * Demande à l'utilisateur de rentrer un pseudo et valide de ce dernier en demandant aux
|
137
|
|
- * utilisateurs distants leurs informations.
|
138
|
|
- * On regarde si le pseudo est bien différent de l'ancien
|
139
|
|
- * </p>
|
140
|
|
- */
|
141
|
|
- private void setPseudo() throws IOException {
|
142
|
|
- String oldPseudo = this.pseudo; //Saves the old one for comparison
|
143
|
|
-
|
144
|
|
- String tmpPseudo = JOptionPane.showInputDialog(null, "Enter nickname:"); // Read user input
|
145
|
|
-
|
146
|
|
- while(!(this.validatePseudo(tmpPseudo)) || tmpPseudo.equals(oldPseudo)) {
|
147
|
|
- tmpPseudo = JOptionPane.showInputDialog(null, "Already exist, enter another nickname :"); // Read user input
|
148
|
|
- }
|
149
|
|
-
|
150
|
|
- this.pseudo = tmpPseudo;
|
151
|
|
- //myObj.close();
|
152
|
|
- JOptionPane.showMessageDialog(null ,"Your new nickname : " + tmpPseudo + " is valid !");
|
153
|
|
-
|
154
|
|
- notify_remote_user();
|
155
|
|
- }
|
156
|
|
-
|
157
|
|
- /**
|
158
|
|
- * <p>
|
159
|
|
- * Demande à l'utilisateur de rentrer un pseudo et valide de ce dernier en demandant aux
|
160
|
|
- * utilisateurs distants leurs informations
|
161
|
|
- * </p>
|
162
|
|
- */
|
163
|
|
- public void initPseudo() throws IOException {
|
164
|
|
- String tmpPseudo = JOptionPane.showInputDialog(null, "Enter nickname:"); // Read user input
|
165
|
|
-
|
166
|
|
- while(!(this.validatePseudo(tmpPseudo))) { // On demande aux autres utilisateurs de nous envoyer leurs informations et on test si le pseudo est déjà utilisé
|
167
|
|
- tmpPseudo = JOptionPane.showInputDialog(null, "Enter another nickname:"); // Read user input
|
168
|
|
- }
|
169
|
|
-
|
170
|
|
- this.pseudo = tmpPseudo;
|
171
|
|
- //sc1.close();
|
172
|
|
- JOptionPane.showMessageDialog(null ,"Your nickname : " + tmpPseudo + " is valid !");
|
173
|
|
- }
|
174
|
|
-
|
175
|
|
- public void TCPmessage(int index) throws IOException {
|
176
|
|
- Socket link=null;
|
177
|
|
- String s1;
|
178
|
|
- try {
|
179
|
|
- link=new Socket(this.userChatList.get(index).addIP,this.userChatList.get(index).portTCP);
|
180
|
|
-
|
181
|
|
- System.out.println("Server is listening on port"+this.portTCP+"of localhost");
|
182
|
|
- }catch(IOException e) {
|
183
|
|
-
|
184
|
|
- System.out.println("Server is not listening on port"+this.portTCP+" of localhost");
|
185
|
|
-
|
186
|
|
- }
|
187
|
|
- BufferedReader in=null;
|
188
|
|
- try {
|
189
|
|
- in = new BufferedReader(new InputStreamReader(link.getInputStream()));
|
190
|
|
- } catch (IOException e) {
|
191
|
|
- // TODO Auto-generated catch block
|
192
|
|
- e.printStackTrace();
|
193
|
|
- }
|
194
|
|
- try {
|
195
|
|
- PrintWriter out = new PrintWriter(link.getOutputStream(),true);
|
196
|
|
- } catch (IOException e) {
|
197
|
|
- // TODO Auto-generated catch block
|
198
|
|
- e.printStackTrace();
|
199
|
|
- }
|
200
|
|
- String input;
|
201
|
|
- String s2 = (this.getPseudo()+" reçoit un message");
|
202
|
|
- try {
|
203
|
|
- while (!(input=in.readLine()).equals("end")) {
|
204
|
|
- System.out.print("client_recoit:"+input);
|
205
|
|
- }
|
206
|
|
- } catch (IOException e) {
|
207
|
|
- // TODO Auto-generated catch block
|
208
|
|
- e.printStackTrace();
|
209
|
|
- }
|
210
|
|
- /*or (int i=0; i<4; i++) {
|
211
|
|
- System.out.println("client envoie");
|
212
|
|
- out.println("coucou \n");
|
213
|
|
- }
|
214
|
|
- out.println("end");*/
|
215
|
|
- try {
|
216
|
|
- link.close();
|
217
|
|
- } catch (IOException e) {
|
218
|
|
- // TODO Auto-generated catch block
|
219
|
|
- e.printStackTrace();
|
220
|
|
- }
|
221
|
|
- }
|
222
|
|
-
|
223
|
|
-
|
224
|
|
- /**
|
225
|
|
- * <p>
|
226
|
|
- * *tmpPseudo : String => Le pseudo à valider
|
227
|
|
- *</p><p>
|
228
|
|
- * Envoi en broadcast (pour l'instant envoi sur les ports de notre ordinateur) d'une demande d'information
|
229
|
|
- *</p><p>
|
230
|
|
- * On attend les réponses pendant 5 secondes
|
231
|
|
- *</p><p>
|
232
|
|
- * On valide le pseudo en fonction des pseudos reçu
|
233
|
|
- *</p><p>
|
234
|
|
- * On en profite pour ajouter les utilisateurs répondant à notre liste d'utilisateur distant (RemoteUser)
|
235
|
|
- * </p>
|
236
|
|
- */
|
237
|
|
- public Boolean validatePseudo(String tmpPseudo) throws IOException {
|
238
|
|
-
|
239
|
|
-
|
240
|
|
- // Call broadcast
|
241
|
|
- InetAddress broadcastIP = InetAddress.getLocalHost(); // change to broadcast
|
242
|
|
- //System.out.println(broadcastIP);
|
243
|
|
- DatagramSocket dgramSocket = new DatagramSocket(this.portUDPsend,this.addIP);
|
244
|
|
- byte[] buffer = new byte[256];
|
245
|
|
-
|
246
|
|
- // Création du message à envoyer
|
247
|
|
- String toSend = this.getAddIP()+":"+this.portUDPsend+":test";
|
248
|
|
-
|
249
|
|
- // Send to remote user 1
|
250
|
|
- DatagramPacket outPacket= new DatagramPacket(toSend.getBytes(), toSend.length(),broadcastIP, portUDPlistening_remoteUsr2);
|
251
|
|
- dgramSocket.send(outPacket);
|
252
|
|
-
|
253
|
|
- // Send to remote user 2
|
254
|
|
- outPacket= new DatagramPacket(toSend.getBytes(), toSend.length(),broadcastIP, portUDPlistening_remoteUsr3);
|
255
|
|
- dgramSocket.send(outPacket);
|
256
|
|
-
|
257
|
|
- // Initialisation des variables de la boucle
|
258
|
|
- Boolean valid = true;
|
259
|
|
-
|
260
|
|
- DatagramPacket inPacket;
|
261
|
|
- String response = null;
|
262
|
|
- String[] tabresponse= new String [4];
|
263
|
|
- dgramSocket.setSoTimeout(1000);
|
264
|
|
- Boolean arecu;
|
265
|
|
-
|
266
|
|
- System.out.print("Wait for pseudo validation ...\n");
|
267
|
|
-
|
268
|
|
- int nbReponse =0;
|
269
|
|
- Date oldDate = new Date();
|
270
|
|
- Date newDate = new Date();
|
271
|
|
- while( (newDate.getTime()-oldDate.getTime()) < 5000 && valid) {
|
272
|
|
-
|
273
|
|
- nbReponse++;
|
274
|
|
- inPacket= new DatagramPacket(buffer, buffer.length);
|
275
|
|
-
|
276
|
|
- arecu=true;
|
277
|
|
- try{
|
278
|
|
- dgramSocket.receive(inPacket);
|
279
|
|
- }catch (Exception e) {
|
280
|
|
- arecu=false;
|
281
|
|
- }
|
282
|
|
- buffer = inPacket.getData();
|
283
|
|
- response = new String(buffer);
|
284
|
|
-
|
285
|
|
- if(arecu) {
|
286
|
|
- // On découpe la réponse en tableau de string ([adresseIP,tcpPort,nickname])
|
287
|
|
- tabresponse = response.split(":");
|
288
|
|
-
|
289
|
|
- // Affichage de la réponse
|
290
|
|
- System.out.println("Remote user n°"+nbReponse+
|
291
|
|
- "\nIP : "+tabresponse[0]+
|
292
|
|
- "\nn°Port : "+tabresponse[1]+
|
293
|
|
- "\npseudo : "+tabresponse[2]);
|
294
|
|
-
|
295
|
|
- // Si reception on ajoute l'utilisateur à notre liste d'utilisateur distant
|
296
|
|
- this.addRemoteUser(InetAddress.getByName(tabresponse[0].split("/")[1]),Integer.parseInt(tabresponse[1]),tabresponse[2]);
|
297
|
|
- valid= (tmpPseudo.compareTo(tabresponse[2])!=0); // On regarde la différence entre notre pseudo et le pseudo reçu
|
298
|
|
-
|
299
|
|
- }
|
300
|
|
-
|
301
|
|
- newDate = new Date();
|
302
|
|
- }
|
303
|
|
- dgramSocket.close();
|
304
|
|
-
|
305
|
|
- if(!valid) {
|
306
|
|
- JOptionPane.showMessageDialog(null ,"Nickname : "+tmpPseudo +" is taken !");
|
307
|
|
- }
|
308
|
|
-
|
309
|
|
- return valid;
|
310
|
|
- }
|
311
|
|
-
|
312
|
|
- /**
|
313
|
|
- * <p>
|
314
|
|
- * *remoteUserIP : InetAddress => l'adresse IP de l'utilisateur distant
|
315
|
|
- * </p><p>
|
316
|
|
- * *remoteUserPortTCP : int => le numéro de port TCP d'écoute de l'utilisateur distant
|
317
|
|
- * </p><p>
|
318
|
|
- * *remoteUserPseudo : String => le pseudo de l'utilisateur distant
|
319
|
|
- * </p><p>
|
320
|
|
- * Ajout ou mise à jour l'utilisateur distant dans notre liste d'utilisateur distant
|
321
|
|
- * </p>
|
322
|
|
- */
|
323
|
|
- public void addRemoteUser(InetAddress remoteUserIP, int remoteUserPortTCP,String remoteUserPseudo) {
|
324
|
|
- RemoteUser tmpRemoteUser = new RemoteUser(remoteUserIP,remoteUserPortTCP,remoteUserPseudo);
|
325
|
|
- int index = this.remoteUserList.indexOf(tmpRemoteUser);
|
326
|
|
- if(index!=-1) {
|
327
|
|
- System.out.println("("+this.pseudo+") - "+"MAJ, IP(port) of user : "+remoteUserPseudo+" => "+remoteUserIP+"("+remoteUserPortTCP+")");
|
328
|
|
- this.remoteUserList.set(index,tmpRemoteUser);
|
329
|
|
- }
|
330
|
|
- else {
|
331
|
|
- System.out.println("("+this.pseudo+") - "+"Add new user IP(port) of user : "+remoteUserPseudo+" => "+remoteUserIP+"("+remoteUserPortTCP+")");
|
332
|
|
- this.remoteUserList.add(tmpRemoteUser);
|
333
|
|
- }
|
334
|
|
- }
|
335
|
|
-
|
336
|
|
- /**
|
337
|
|
- * <p>
|
338
|
|
- * En utilisant le port UDP d'envoi, on envoie en broadcast les informations nous concernant
|
339
|
|
- * </p>
|
340
|
|
- */
|
341
|
|
- public void notify_remote_user() {
|
342
|
|
- // Création du socket d'envoi d'information
|
343
|
|
- DatagramSocket dgramSocket= null;
|
344
|
|
- try {
|
345
|
|
- dgramSocket= new DatagramSocket(portUDPsend,this.addIP);
|
346
|
|
- } catch (IOException e) {
|
347
|
|
- e.printStackTrace();
|
348
|
|
- }
|
349
|
|
-
|
350
|
|
- // Construction du message à envoyer
|
351
|
|
- String toSend = this.addIP.toString()+":"+this.portTCP+":"+this.pseudo+":test";
|
352
|
|
-
|
353
|
|
- DatagramPacket outPacket =null;
|
354
|
|
-
|
355
|
|
- // Send information to usr2
|
356
|
|
- if(this.portUDPlistening!=portUDPlistening_remoteUsr2) {
|
357
|
|
- outPacket = new DatagramPacket(toSend.getBytes(), toSend.length(),this.addIP, portUDPlistening_remoteUsr2);
|
358
|
|
- try {
|
359
|
|
- dgramSocket.send(outPacket);
|
360
|
|
- } catch (IOException e) {
|
361
|
|
- e.printStackTrace();
|
362
|
|
- }
|
363
|
|
- }
|
364
|
|
-
|
365
|
|
-
|
366
|
|
- // Send information to usr3
|
367
|
|
- if(this.portUDPlistening!=portUDPlistening_remoteUsr3) {
|
368
|
|
-
|
369
|
|
- outPacket= new DatagramPacket(toSend.getBytes(), toSend.length(),this.addIP, portUDPlistening_remoteUsr3);
|
370
|
|
- try {
|
371
|
|
- dgramSocket.send(outPacket);
|
372
|
|
- } catch (IOException e) {
|
373
|
|
- e.printStackTrace();
|
374
|
|
- }
|
375
|
|
- }
|
376
|
|
- dgramSocket.close();
|
377
|
|
- }
|
378
|
|
-
|
379
|
|
- /**
|
380
|
|
- * <p>
|
381
|
|
- * On démarre un thread d'écoute UDP pour répondre au nouveaux utilisateurs,
|
382
|
|
- * </p><p>
|
383
|
|
- * On démarre un thread d'écoute TCP pour commencer une conversation avec les utilisateurs actifs,
|
384
|
|
- * </p><p>
|
385
|
|
- * On notifie les utilisateurs distants actifs de notre passage en mode actif (envoi de nos informations)
|
386
|
|
- * </p>
|
387
|
|
- */
|
388
|
|
- private void active() {
|
389
|
|
- this.threadListeningUDP = new UserListeningThreadUDP("UDP Listening thread",this);
|
390
|
|
- this.threadListeningUDP.start();
|
391
|
|
-
|
392
|
|
- this.threadListeningTCP = new UserListeningThreadTCP("TCP main Listening thread",this);
|
393
|
|
- this.threadListeningTCP.start();
|
394
|
|
-
|
395
|
|
- notify_remote_user();
|
396
|
|
-
|
397
|
|
- this.actif=true;
|
398
|
|
- }
|
399
|
|
-
|
400
|
|
- /**
|
401
|
|
- * <p>
|
402
|
|
- * Affichage de la liste d'utilisateurs actifs avec leurs index dans la liste
|
403
|
|
- * </p>
|
404
|
|
- */
|
405
|
|
- public void printRemoteUserList() {
|
406
|
|
- System.out.println("Internal list of active remote users:");
|
407
|
|
-
|
408
|
|
- for(int i=0; i<this.remoteUserList.size(); i++) {
|
409
|
|
- System.out.println("- ("+i+") Username: " + this.remoteUserList.get(i).getPseudo());
|
410
|
|
- }
|
411
|
|
- }
|
412
|
|
-
|
413
|
|
- /**
|
414
|
|
- * <p>
|
415
|
|
- * Laisse l'utilisateur choisir parmis la liste d'utilisateurs actifs celui avec lequel il souhaite échanger via un chat
|
416
|
|
- *</p>
|
417
|
|
- */
|
418
|
|
- public void getOneActiveUser() throws IOException {
|
419
|
|
- this.printRemoteUserList();
|
420
|
|
- int index=Integer.parseInt(JOptionPane.showInputDialog(null, "Please, enter index of one active user that you saw on the list to start a conversation with:"));
|
421
|
|
-
|
422
|
|
- if (index >= 0 && index<remoteUserList.size()) {
|
423
|
|
- if(userChatList.contains(remoteUserList.get(index))) {
|
424
|
|
- JOptionPane.showMessageDialog(null ,"User "+remoteUserList.get(index).getPseudo()+" is already in chat with you");
|
425
|
|
- }
|
426
|
|
- else {
|
427
|
|
- userChatList.add(remoteUserList.get(index));
|
428
|
|
- JOptionPane.showMessageDialog(null ,"New chat with "+remoteUserList.get(index).getPseudo());
|
429
|
|
- }
|
430
|
|
- }
|
431
|
|
- else {
|
432
|
|
- JOptionPane.showMessageDialog(null ,"Wrong index (no active at index number "+index+" )");
|
433
|
|
- }
|
434
|
|
-
|
435
|
|
- this.TCPmessage(index);
|
436
|
|
- //sc2.close();
|
437
|
|
- }
|
438
|
|
-
|
439
|
|
- public static void main(String[] args) throws IOException, InterruptedException {
|
440
|
|
- // Création des utilisateurs
|
441
|
|
- User usr2 = new User(12226,portUDPlistening_remoteUsr2,22222,"Mike"); // simulation d'un utilisateur distant n1
|
442
|
|
- User usr3 = new User(12224,portUDPlistening_remoteUsr3,22223,"Alice"); // simulation d'un utilisateur distant n2
|
443
|
|
- User usr1 = new User(12225,20001,22221); // Notre utilisateur local
|
444
|
|
-
|
445
|
|
- // Fonction appelé par notre utilisateur local
|
446
|
|
- usr1.getOneActiveUser();
|
447
|
|
- usr1.setPseudo();
|
448
|
|
-
|
449
|
|
- // On attends 5 secondes
|
450
|
|
- System.out.println("Sleep mode for 5 seconds");
|
451
|
|
- Thread.sleep(5000);
|
452
|
|
- // On ferme les différents threads et socket d'écoute
|
453
|
|
-
|
454
|
|
-
|
455
|
|
-
|
456
|
|
- usr1.threadListeningUDP.close();
|
457
|
|
- usr2.threadListeningUDP.close();
|
458
|
|
- usr3.threadListeningUDP.close();
|
459
|
|
-
|
460
|
|
- usr1.threadListeningTCP.close();
|
461
|
|
- usr2.threadListeningTCP.close();
|
462
|
|
- usr3.threadListeningTCP.close();
|
463
|
|
- JOptionPane.showMessageDialog(null ,"End");
|
464
|
|
-
|
465
|
|
-
|
466
|
|
- }
|
467
|
|
-}
|