commentaires + 2eme RemoteUser
This commit is contained in:
parent
39b24741a3
commit
0bb9c560b1
6 changed files with 126 additions and 98 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -3,12 +3,12 @@ import java.net.InetAddress;
|
||||||
public class RemoteUser {
|
public class RemoteUser {
|
||||||
|
|
||||||
InetAddress addIP;
|
InetAddress addIP;
|
||||||
int nPort;
|
int portTCP;
|
||||||
String pseudo;
|
String pseudo;
|
||||||
|
|
||||||
public RemoteUser(InetAddress remoteUserIP, int remoteUserPort,String pseudo) {
|
public RemoteUser(InetAddress remoteUserIP, int remoteUserPortTCP,String pseudo) {
|
||||||
this.addIP=remoteUserIP;
|
this.addIP=remoteUserIP;
|
||||||
this.nPort=remoteUserPort;
|
this.portTCP=remoteUserPortTCP;
|
||||||
this.pseudo=pseudo;
|
this.pseudo=pseudo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,11 +21,11 @@ public class RemoteUser {
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getRemoteUserPort() {
|
public int getRemoteUserPort() {
|
||||||
return nPort;
|
return portTCP;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRemoteUserPort(int remoteUserPort) {
|
public void setRemoteUserPort(int remoteUserPort) {
|
||||||
this.nPort = remoteUserPort;
|
this.portTCP = remoteUserPort;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPseudo() {
|
public String getPseudo() {
|
||||||
|
@ -49,7 +49,7 @@ public class RemoteUser {
|
||||||
if (addIP == null) {
|
if (addIP == null) {
|
||||||
if (other.addIP != null)
|
if (other.addIP != null)
|
||||||
return false;
|
return false;
|
||||||
} else if (!addIP.equals(other.addIP))
|
} else if (!(addIP.equals(other.addIP) && portTCP==other.portTCP))
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,28 +6,31 @@ import java.util.ArrayList; // import the ArrayList class
|
||||||
|
|
||||||
|
|
||||||
public class User{
|
public class User{
|
||||||
final static int portUDPlistening_remoteUsr1 = 20001;
|
|
||||||
|
/*** CONSTANTES ***/
|
||||||
|
final static int portUDPlistening_remoteUsr2 = 20002;
|
||||||
|
final static int portUDPlistening_remoteUsr3 = 20003;
|
||||||
|
|
||||||
|
/*** VARIABLES ***/
|
||||||
protected InetAddress addIP;
|
protected InetAddress addIP;
|
||||||
protected String pseudo;
|
protected String pseudo;
|
||||||
|
|
||||||
protected int portUDPsend;
|
protected int portUDPsend;
|
||||||
protected int portUDPlistening;
|
protected int portUDPlistening;
|
||||||
protected int portTCP;
|
protected int portTCP;
|
||||||
|
|
||||||
protected boolean actif;
|
protected boolean actif;
|
||||||
|
|
||||||
protected ArrayList<RemoteUser> remoteUserList = new ArrayList<RemoteUser>();
|
protected ArrayList<RemoteUser> remoteUserList = new ArrayList<RemoteUser>(); // listes des utilisateurs actifs
|
||||||
protected ArrayList<RemoteUser> userChatList = new ArrayList<RemoteUser>();
|
protected ArrayList<RemoteUser> userChatList = new ArrayList<RemoteUser>(); // listes des utilisateurs avec qui un chat est actif
|
||||||
|
|
||||||
protected UserListeningThread threadListeningUDP;
|
protected UserListeningThread threadListeningUDP; // UDP listening thread (pour répondre aux nouveaux utilisateurs)
|
||||||
public Boolean stopListeningUDPThread=false;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Constructor of User
|
* Constructor of User
|
||||||
* parameters
|
* $parameters
|
||||||
* #nport
|
* *
|
||||||
* description : On récupère l'adresse de la machine, le numéro de port à utiliser(TODO), on demande un pseudo à l'utilisateur
|
* *
|
||||||
|
* *
|
||||||
|
* $description : On récupère l'adresse de la machine, le numéro de port à utiliser(TODO), on demande un pseudo à l'utilisateur
|
||||||
* que l'on vérifie, une fois validé, l'utilisateur devient actif (Début de l'écoute UDP pour les pseudos)
|
* que l'on vérifie, une fois validé, l'utilisateur devient actif (Début de l'écoute UDP pour les pseudos)
|
||||||
*/
|
*/
|
||||||
public User(int portUDPsend,int portUDPlistening,int portTCP) throws IOException{
|
public User(int portUDPsend,int portUDPlistening,int portTCP) throws IOException{
|
||||||
|
@ -44,28 +47,20 @@ public class User{
|
||||||
this.portUDPlistening = portUDPlistening;
|
this.portUDPlistening = portUDPlistening;
|
||||||
this.portTCP = portTCP;
|
this.portTCP = portTCP;
|
||||||
|
|
||||||
this.setPseudo();
|
this.initPseudo();
|
||||||
|
|
||||||
this.setActif(true);
|
this.setActif(true);
|
||||||
|
|
||||||
|
|
||||||
//ask_change_pseudo();
|
|
||||||
/*
|
|
||||||
boolean wantstochange = true; //A faire avec un bouton dans SWING
|
|
||||||
if(wantstochange) {
|
|
||||||
//changePseudo();
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
//this.waitProgramtoStop()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* remoteUser
|
/*
|
||||||
* Constructor of User simuled a remote user (Already log into our system)
|
* Constructor of User (simulation des utilisateurs distants)
|
||||||
* parameters
|
* $parameters
|
||||||
* #nport
|
* *
|
||||||
* #pseudo
|
* *
|
||||||
* description : On récupère l'adresse de la machine, le numéro de port à utiliser(TODO), on demande un pseudo à l'utilisateur
|
* *
|
||||||
* que l'on vérifie, une fois validé, l'utilisateur devient actif (Début de l'écoute UDP pour les pseudos)
|
* $description : On récupère l'adresse de la machine, le numéro de port à utiliser(TODO), on demande un pseudo à l'utilisateur
|
||||||
|
* que l'on vérifie, une fois validé, l'utilisateur devient actif (Début de l'écoute UDP pour les pseudos)
|
||||||
*/
|
*/
|
||||||
public User(int portUDPsend,int portUDPlistening, int portTCP,String pseudo) {
|
public User(int portUDPsend,int portUDPlistening, int portTCP,String pseudo) {
|
||||||
try
|
try
|
||||||
|
@ -84,53 +79,46 @@ public class User{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*** GETTER ***/
|
||||||
public InetAddress getAddIP() {
|
public InetAddress getAddIP() {
|
||||||
return addIP;
|
return addIP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void setAddIP(InetAddress addIP) {
|
|
||||||
this.addIP = addIP;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public String getPseudo() {
|
public String getPseudo() {
|
||||||
return pseudo;
|
return pseudo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPortTCP() {
|
public int getPortTCP() {
|
||||||
return portTCP;
|
return portTCP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void setPortTCP(int portTCP) {
|
|
||||||
this.portTCP = portTCP;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getPortUDPlistening() {
|
public int getPortUDPlistening() {
|
||||||
return portUDPlistening;
|
return portUDPlistening;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getPortUDPsend() {
|
||||||
|
return portUDPsend;
|
||||||
|
}
|
||||||
|
public boolean isActif() {
|
||||||
|
return actif;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*** SETTER ***/
|
||||||
|
public void setAddIP(InetAddress addIP) {
|
||||||
|
this.addIP = addIP;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPortTCP(int portTCP) {
|
||||||
|
this.portTCP = portTCP;
|
||||||
|
}
|
||||||
|
|
||||||
public void setPortUDPlistening(int portUDPlistening) {
|
public void setPortUDPlistening(int portUDPlistening) {
|
||||||
this.portUDPlistening = portUDPlistening;
|
this.portUDPlistening = portUDPlistening;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPortUDPsend() {
|
|
||||||
return portUDPsend;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void setPortUDPsend(int portUDPsend) {
|
public void setPortUDPsend(int portUDPsend) {
|
||||||
this.portUDPsend = portUDPsend;
|
this.portUDPsend = portUDPsend;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isActif() {
|
|
||||||
return actif;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void setActif(boolean actif) {
|
public void setActif(boolean actif) {
|
||||||
notify_remote_user();
|
notify_remote_user();
|
||||||
this.threadListeningUDP = new UserListeningThread("UDP Listening thread",this);
|
this.threadListeningUDP = new UserListeningThread("UDP Listening thread",this);
|
||||||
|
@ -139,7 +127,13 @@ public class User{
|
||||||
this.actif=true;
|
this.actif=true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*** PROCEDURES ***/
|
||||||
|
|
||||||
|
/* notify_remote_user
|
||||||
|
* En utilisant le port UDP d'envoi, on envoi en broadcast les informations nous concernant
|
||||||
|
*/
|
||||||
public void notify_remote_user() {
|
public void notify_remote_user() {
|
||||||
|
// Création du socket d'envoi d'information
|
||||||
DatagramSocket dgramSocket= null;
|
DatagramSocket dgramSocket= null;
|
||||||
try {
|
try {
|
||||||
dgramSocket= new DatagramSocket(portUDPsend,this.addIP);
|
dgramSocket= new DatagramSocket(portUDPsend,this.addIP);
|
||||||
|
@ -147,24 +141,38 @@ public class User{
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Construction du message à envoyer
|
||||||
String toSend = this.addIP.toString()+":"+this.portTCP+":"+this.pseudo+":test";
|
String toSend = this.addIP.toString()+":"+this.portTCP+":"+this.pseudo+":test";
|
||||||
//System.out.println("Message avant envoi " +toSend);
|
|
||||||
DatagramPacket outPacket= new DatagramPacket(toSend.getBytes(), toSend.length(),this.addIP, portUDPlistening_remoteUsr1);
|
|
||||||
|
// Send information to usr2
|
||||||
|
DatagramPacket outPacket= new DatagramPacket(toSend.getBytes(), toSend.length(),this.addIP, portUDPlistening_remoteUsr2);
|
||||||
try {
|
try {
|
||||||
dgramSocket.send(outPacket);
|
dgramSocket.send(outPacket);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Send information to usr3
|
||||||
|
outPacket= new DatagramPacket(toSend.getBytes(), toSend.length(),this.addIP, portUDPlistening_remoteUsr3);
|
||||||
|
try {
|
||||||
|
dgramSocket.send(outPacket);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
dgramSocket.close();
|
dgramSocket.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPseudo() throws IOException {
|
/*initPseudo
|
||||||
|
* Demande à l'utilisateur de rentrer un pseudo et validation de ce dernier en demandant aux utilisateurs distants leurs informations
|
||||||
|
*/
|
||||||
|
public void initPseudo() throws IOException {
|
||||||
Scanner sc1 = new Scanner(System.in); // Create a Scanner object
|
Scanner sc1 = new Scanner(System.in); // Create a Scanner object
|
||||||
System.out.println("Enter nickname :");
|
System.out.println("Enter nickname :");
|
||||||
String tmpPseudo = sc1.nextLine(); // Read user input
|
String tmpPseudo = sc1.nextLine(); // Read user input
|
||||||
|
|
||||||
while(!(this.validatePseudo(tmpPseudo))) {
|
while(!(this.validatePseudo(tmpPseudo))) { // On demande aux autres utilisateurs de nous envoyer leurs informations et on test si le pseudo est déjà utilisé
|
||||||
System.out.println("Enter another nickname :");
|
System.out.println("Enter another nickname :");
|
||||||
tmpPseudo = sc1.nextLine(); // Read user input
|
tmpPseudo = sc1.nextLine(); // Read user input
|
||||||
}
|
}
|
||||||
|
@ -174,6 +182,15 @@ public class User{
|
||||||
System.out.println("Your nickname : " + tmpPseudo + " is valid !");
|
System.out.println("Your nickname : " + tmpPseudo + " is valid !");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* validatePseudo
|
||||||
|
* $parametres
|
||||||
|
* *tmpPseudo : String => Le pseudo à valider
|
||||||
|
* $description
|
||||||
|
* On envoi en broadcast (pour l'instant envoi sur les ports de notre ordinateur) d'une demande d'information
|
||||||
|
* On attends les réponses pendant 5 secondes
|
||||||
|
* On valide le pseudo en fonction des pseudos reçu
|
||||||
|
* On en profites pour ajouter les utilisateurs répondant à notre liste d'utilisateur distant (RemoteUser)
|
||||||
|
*/
|
||||||
public Boolean validatePseudo(String tmpPseudo) throws IOException {
|
public Boolean validatePseudo(String tmpPseudo) throws IOException {
|
||||||
|
|
||||||
|
|
||||||
|
@ -181,19 +198,24 @@ public class User{
|
||||||
InetAddress broadcastIP = InetAddress.getLocalHost(); // change to broadcast
|
InetAddress broadcastIP = InetAddress.getLocalHost(); // change to broadcast
|
||||||
//System.out.println(broadcastIP);
|
//System.out.println(broadcastIP);
|
||||||
DatagramSocket dgramSocket = new DatagramSocket(this.portUDPsend,this.addIP);
|
DatagramSocket dgramSocket = new DatagramSocket(this.portUDPsend,this.addIP);
|
||||||
|
|
||||||
byte[] buffer = new byte[256];
|
byte[] buffer = new byte[256];
|
||||||
|
|
||||||
|
// Création du message à envoyer
|
||||||
String toSend = this.getAddIP()+":"+this.portUDPsend+":test";
|
String toSend = this.getAddIP()+":"+this.portUDPsend+":test";
|
||||||
DatagramPacket outPacket= new DatagramPacket(toSend.getBytes(), toSend.length(),broadcastIP, portUDPlistening_remoteUsr1);
|
|
||||||
|
// Send to remote user 1
|
||||||
|
DatagramPacket outPacket= new DatagramPacket(toSend.getBytes(), toSend.length(),broadcastIP, portUDPlistening_remoteUsr2);
|
||||||
dgramSocket.send(outPacket);
|
dgramSocket.send(outPacket);
|
||||||
|
|
||||||
Boolean valid = true;
|
// Send to remote user 2
|
||||||
|
outPacket= new DatagramPacket(toSend.getBytes(), toSend.length(),broadcastIP, portUDPlistening_remoteUsr3);
|
||||||
Date oldDate = new Date();
|
dgramSocket.send(outPacket);
|
||||||
Date newDate = new Date();
|
|
||||||
|
|
||||||
|
// Initialisation des paramètres de la boucles
|
||||||
|
Boolean valid = true;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
DatagramPacket inPacket;
|
DatagramPacket inPacket;
|
||||||
String response = null;
|
String response = null;
|
||||||
String[] lstresponse= new String [4];
|
String[] lstresponse= new String [4];
|
||||||
|
@ -203,6 +225,8 @@ public class User{
|
||||||
System.out.print("Wait for pseudo validation ...\n");
|
System.out.print("Wait for pseudo validation ...\n");
|
||||||
|
|
||||||
int nbReponse =0;
|
int nbReponse =0;
|
||||||
|
Date oldDate = new Date();
|
||||||
|
Date newDate = new Date();
|
||||||
while( (newDate.getTime()-oldDate.getTime()) < 5000 && valid) {
|
while( (newDate.getTime()-oldDate.getTime()) < 5000 && valid) {
|
||||||
|
|
||||||
nbReponse++;
|
nbReponse++;
|
||||||
|
@ -217,18 +241,19 @@ public class User{
|
||||||
buffer = inPacket.getData();
|
buffer = inPacket.getData();
|
||||||
response = new String(buffer);
|
response = new String(buffer);
|
||||||
|
|
||||||
if(arecu) {
|
if(arecu) {
|
||||||
//System.out.println("Reponse : "+response);
|
// On découpe la réponse en tableau de string ([adresseIP,tcpPort,nickname])
|
||||||
|
|
||||||
lstresponse = response.split(":");
|
lstresponse = response.split(":");
|
||||||
|
|
||||||
|
// Affichage de la réponse
|
||||||
System.out.println("Remote user n°"+nbReponse);
|
System.out.println("Remote user n°"+nbReponse);
|
||||||
System.out.println("\tIP : "+lstresponse[0]);
|
System.out.println("\tIP : "+lstresponse[0]);
|
||||||
System.out.println("\tn°Port : "+lstresponse[1]);
|
System.out.println("\tn°Port : "+lstresponse[1]);
|
||||||
System.out.println("\tpseudo : "+lstresponse[2]);
|
System.out.println("\tpseudo : "+lstresponse[2]);
|
||||||
|
|
||||||
|
// Si reception on ajoute l'utilisateur à notre liste d'utilisateur distant
|
||||||
this.addRemoteUser(InetAddress.getByName(lstresponse[0].split("/")[1]),Integer.parseInt(lstresponse[1]),lstresponse[2]);
|
this.addRemoteUser(InetAddress.getByName(lstresponse[0].split("/")[1]),Integer.parseInt(lstresponse[1]),lstresponse[2]);
|
||||||
valid= (tmpPseudo.compareTo(lstresponse[2])!=0);
|
valid= (tmpPseudo.compareTo(lstresponse[2])!=0); // On regarde la différence entre notre pseudo et le pseudo reçu
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -257,7 +282,7 @@ public class User{
|
||||||
}
|
}
|
||||||
// change pseudo
|
// change pseudo
|
||||||
|
|
||||||
private void changePseudo() throws IOException { //seule différence avec setPseudo c'est qu'on check si on remet pas le même
|
private void setPseudo() throws IOException { //seule différence avec setPseudo c'est qu'on check si on remet pas le même
|
||||||
String oldPseudo = this.pseudo; //Saves the old one for comparison
|
String oldPseudo = this.pseudo; //Saves the old one for comparison
|
||||||
|
|
||||||
Scanner sc3 = new Scanner(System.in); // Create a Scanner object
|
Scanner sc3 = new Scanner(System.in); // Create a Scanner object
|
||||||
|
@ -275,23 +300,25 @@ private void changePseudo() throws IOException { //seule diff
|
||||||
|
|
||||||
notify_remote_user();
|
notify_remote_user();
|
||||||
}
|
}
|
||||||
|
/*printRemoteUserList
|
||||||
|
* $descrition
|
||||||
|
* Affichage de la liste d'utilisateur actif avec leurs index dans la liste
|
||||||
|
*/
|
||||||
public void printRemoteUserList() {
|
public void printRemoteUserList() {
|
||||||
System.out.println("Internal list of remote users:\n");
|
System.out.println("Internal list of active remote users:\n");
|
||||||
|
|
||||||
for(int i=0; i<this.remoteUserList.size(); i++) {
|
for(int i=0; i<this.remoteUserList.size(); i++) {
|
||||||
String pseudo = this.remoteUserList.get(i).getPseudo();
|
System.out.println("- ("+i+") Username: " + this.remoteUserList.get(i).getPseudo());
|
||||||
int Port = this.remoteUserList.get(i).getRemoteUserPort();
|
|
||||||
|
|
||||||
System.out.println("("+i+")"
|
|
||||||
+"Username: " + pseudo + "\n"
|
|
||||||
+ "IP Adress: " + this.remoteUserList.get(i).getRemoteUserIP() + "\n"
|
|
||||||
+ "Port: " + Port + "\n" + "\n");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*getOneActiveUser
|
||||||
|
* $description
|
||||||
|
* Laisse l'utilisateur choisir parmis la liste d'utilisateur actif celui avec lequel il souhaite échangé via un chat
|
||||||
|
*/
|
||||||
public void getOneActiveUser() throws UnknownHostException {
|
public void getOneActiveUser() throws UnknownHostException {
|
||||||
Scanner sc2= new Scanner(System.in);
|
this.printRemoteUserList();
|
||||||
|
Scanner sc2= new Scanner(System.in);
|
||||||
System.out.println("Please, enter one active user that you saw on the list to start a conversation with");
|
System.out.println("Please, enter one active user that you saw on the list to start a conversation with");
|
||||||
int index=Integer.parseInt(sc2.nextLine());
|
int index=Integer.parseInt(sc2.nextLine());
|
||||||
|
|
||||||
|
@ -309,25 +336,26 @@ private void changePseudo() throws IOException { //seule diff
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) throws IOException, InterruptedException {
|
public static void main(String[] args) throws IOException, InterruptedException {
|
||||||
User usr1 = new User(12221,portUDPlistening_remoteUsr1,22221,"Mike");
|
|
||||||
|
|
||||||
User usr2 = new User(12222,20002,22222);
|
// Création des utilisateurs
|
||||||
|
User usr2 = new User(12222,portUDPlistening_remoteUsr2,22222,"Mike"); // simulation d'un utilisateur distant n1
|
||||||
|
User usr3 = new User(12223,portUDPlistening_remoteUsr3,22223,"Alice"); // simulation d'un utilisateur distant n2
|
||||||
|
User usr1 = new User(12221,20001,22221); // Notre utilisateur locale
|
||||||
|
|
||||||
|
// Fonction appelé par notre utilisateur locale
|
||||||
|
usr1.printRemoteUserList();
|
||||||
|
usr1.getOneActiveUser();
|
||||||
|
usr1.setPseudo();
|
||||||
|
|
||||||
//User usr3 = new User(12229);
|
// On attends 5 secondes
|
||||||
|
|
||||||
// Attend une réponse pour fermer l'écoute UDP
|
|
||||||
usr2.printRemoteUserList();
|
|
||||||
usr2.getOneActiveUser();
|
|
||||||
|
|
||||||
usr2.changePseudo();
|
|
||||||
|
|
||||||
System.out.println("Sleep mode for 5 seconds");
|
System.out.println("Sleep mode for 5 seconds");
|
||||||
Thread.sleep(5000);
|
Thread.sleep(5000);
|
||||||
|
// On ferme les différents threads et socket d'écoute
|
||||||
usr1.threadListeningUDP.close();
|
usr1.threadListeningUDP.close();
|
||||||
usr2.threadListeningUDP.close();
|
usr2.threadListeningUDP.close();
|
||||||
System.out.println("Fin du programme");
|
usr3.threadListeningUDP.close();
|
||||||
|
|
||||||
|
System.out.println("End");
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,7 +83,7 @@ public class UserListeningThread extends Thread{
|
||||||
|
|
||||||
public void close() {
|
public void close() {
|
||||||
this.dgramSocket.close();
|
this.dgramSocket.close();
|
||||||
System.out.println("Fin du thread "+this.myUser.getPseudo());
|
System.out.println("End of listing thread ("+this.myUser.getPseudo()+")");
|
||||||
try {
|
try {
|
||||||
this.interrupt();
|
this.interrupt();
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
|
|
Loading…
Reference in a new issue