Skip to content

Commit

Permalink
au bout
Browse files Browse the repository at this point in the history
  • Loading branch information
ElyesKhama committed Dec 22, 2017
1 parent 9bc3923 commit 4402438
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/GraphiquePackage/FichCom.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public void exitSystem(){
this.addWindowListener(new java.awt.event.WindowAdapter() {
@Override
public void windowClosing(java.awt.event.WindowEvent e) {
Main.user.sendMessageUDP("quito");
Main.user.sendMessageUDP("quito",portDest);
System.out.println("jai send le msg" );
System.exit(0);
}
Expand Down
2 changes: 1 addition & 1 deletion src/GraphiquePackage/FichMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public void exitSystem(){
this.addWindowListener(new java.awt.event.WindowAdapter() {
@Override
public void windowClosing(java.awt.event.WindowEvent e) {
Main.user.sendMessageUDP("quita");
Main.user.sendMessageUDP("quita",0);
System.out.println("jai send le msg" );
System.exit(0);
}
Expand Down
1 change: 1 addition & 0 deletions src/SourcePackage/ThreadReceive.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public static void receiveMessage() throws IOException { //UDP : boucle qui re
}

else if(recvStr.contains("quito")){
System.out.print("etat du socket : "+ User.getSocketEcoute());
Main.user.removeSocketList(recvPacket.getPort());
}

Expand Down
9 changes: 3 additions & 6 deletions src/SourcePackage/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public User(String pseudo){
}

public void startThread(){
sendMessageUDP(null);
sendMessageUDP(null,0);

Thread threadReceive = new ThreadReceive("thread receive");
threadReceive.start();
Expand All @@ -52,11 +52,12 @@ public void startThread(){

}

public void sendMessageUDP(String message){
public void sendMessageUDP(String message,int port){
String data = "" ;

if(message != null ){
data = message+"-"+pseudo;
listSocket.remove(port);
}
else {
data = Main.user.getPseudo();
Expand Down Expand Up @@ -160,15 +161,11 @@ public void removeUserList(String pseudo1){

public void removeSocketList(int port){
System.out.println("J'ai fermé la co !!! ");
System.out.println("Etat du socket avant : "+ listSocket.get(port).isConnected());

try {
listSocket.get(port).close();
} catch (IOException ex) {
Logger.getLogger(User.class.getName()).log(Level.SEVERE, null, ex);
}
System.out.println("Etat du socket apres : "+ listSocket.get(port).isConnected());

this.listSocket.remove(port);
}

Expand Down

0 comments on commit 4402438

Please sign in to comment.