Skip to content

Commit e4408b1

Browse files
authored
Add files via upload
1 parent 50b64e8 commit e4408b1

10 files changed

Lines changed: 5 additions & 14 deletions

File tree

36 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
57 Bytes
Binary file not shown.

clientSocket/src/Client.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,13 @@ public void work(String messaggio) {
100100

101101
while (readThread.isAlive() && writeThread.isAlive());
102102
String message = readThread.getMessage();
103+
103104
txtRisultato.setText(message);
104105

106+
if(message.equals("")) {
107+
work(messaggio);
108+
}
109+
105110
} catch (Exception ex) {
106111
JOptionPane.showMessageDialog(this, ex.getMessage(), "ERROR", JOptionPane.ERROR_MESSAGE);
107112
}
719 Bytes
Binary file not shown.
16 Bytes
Binary file not shown.
390 Bytes
Binary file not shown.

serverSocket/src/Server.java

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ public Server() throws Exception {
4343
public void run() {
4444
try {
4545
messaggia(clientSocket);
46-
writeMessageToFile(username, message);
4746
} catch (Exception ex) {
4847
System.err.println(ex.getMessage());
4948
}
@@ -98,19 +97,6 @@ public void messaggia(Socket clientSocket) throws Exception
9897
stop();
9998
}
10099

101-
public void writeMessageToFile(String username, String message) throws Exception
102-
{
103-
File file = new File(getClass().getResource("chat.txt").getFile());
104-
105-
if(!file.exists())
106-
file.createNewFile();
107-
108-
FileWriter fileWriter = new FileWriter(file);
109-
if(message!=null)
110-
fileWriter.write(username + ";" + message + ";" + LocalDateTime.now() + "\n");
111-
fileWriter.close();
112-
}
113-
114100
/**
115101
* Accetta la richiesta di connessione da parte del client ed elabora l'input
116102
* @throws Exception se il metodo stop() lancia un'eccezzione

0 commit comments

Comments
 (0)