-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLogout.java
More file actions
34 lines (25 loc) · 832 Bytes
/
Copy pathLogout.java
File metadata and controls
34 lines (25 loc) · 832 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package turing;
import java.nio.channels.SocketChannel;
import turing.Message.OPERATION;
public class Logout implements Runnable {
SocketChannel client; //socket a cui invia l'esito
Message received;
public Logout(SocketChannel c, Message received){
this.client = c;
this.received = received;
}
public void run() {
Message toSend = new Message();
try
{
Message.RESULT result = Turing.databaseUsers.setOffline(received.getUsername());
//setOffline chiude socket del login e imposta socket associata all'utente a null
System.out.println("Server-Logout ["+ received.getUsername()+"]: "+ result);
toSend.setMessageResult(OPERATION.LOGOUT,result);
Message.sendMessage(client, toSend);
client.close(); //socket a cui invia l'esito
} catch (Exception e){
e.printStackTrace();
}
}
}