Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
LuMarans30 authored Oct 24, 2022
1 parent 50b64e8 commit e4408b1
Show file tree
Hide file tree
Showing 10 changed files with 5 additions and 14 deletions.
Binary file modified clientSocket/out/artifacts/maranoclientSocket_jar/clientSocket.jar
Binary file not shown.
Binary file modified clientSocket/out/production/clientSocket/Client$1.class
Binary file not shown.
Binary file modified clientSocket/out/production/clientSocket/Client$2.class
Binary file not shown.
Binary file modified clientSocket/out/production/clientSocket/Client$3.class
Binary file not shown.
Binary file modified clientSocket/out/production/clientSocket/Client.class
Binary file not shown.
5 changes: 5 additions & 0 deletions clientSocket/src/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,13 @@ public void work(String messaggio) {

while (readThread.isAlive() && writeThread.isAlive());
String message = readThread.getMessage();

txtRisultato.setText(message);

if(message.equals("")) {
work(messaggio);
}

} catch (Exception ex) {
JOptionPane.showMessageDialog(this, ex.getMessage(), "ERROR", JOptionPane.ERROR_MESSAGE);
}
Expand Down
Binary file modified serverSocket/out/artifacts/serverSocket_jar/serverSocket.jar
Binary file not shown.
Binary file modified serverSocket/out/production/serverSocket/ReadThread.class
Binary file not shown.
Binary file modified serverSocket/out/production/serverSocket/Server.class
Binary file not shown.
14 changes: 0 additions & 14 deletions serverSocket/src/Server.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ public Server() throws Exception {
public void run() {
try {
messaggia(clientSocket);
writeMessageToFile(username, message);
} catch (Exception ex) {
System.err.println(ex.getMessage());
}
Expand Down Expand Up @@ -98,19 +97,6 @@ public void messaggia(Socket clientSocket) throws Exception
stop();
}

public void writeMessageToFile(String username, String message) throws Exception
{
File file = new File(getClass().getResource("chat.txt").getFile());

if(!file.exists())
file.createNewFile();

FileWriter fileWriter = new FileWriter(file);
if(message!=null)
fileWriter.write(username + ";" + message + ";" + LocalDateTime.now() + "\n");
fileWriter.close();
}

/**
* Accetta la richiesta di connessione da parte del client ed elabora l'input
* @throws Exception se il metodo stop() lancia un'eccezzione
Expand Down

0 comments on commit e4408b1

Please sign in to comment.