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 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
| public synchronized void deleteAllStreams()
{
Set keys = clients.keySet();
Iterator it = keys.iterator();
while(it.hasNext())
{
String key = (String)it.next();
deleteStreams(key);
removeClient(key);
}
}
private synchronized void deleteStreams(String key)
{
Hashtable streams;
streams = (Hashtable) clients.get(key);
if (streams != null)
{
ObjectOutputStream output = (ObjectOutputStream) streams.get("output");
try
{
output.flush();
}
catch (IOException e)
{
System.out.println("Flush sortie client : " + e.getMessage());
}
try
{
output.close();
}
catch (IOException e)
{
System.out.println("Fermeture sortie client : " + e.getMessage());
}
ObjectInputStream input = (ObjectInputStream) streams.get("input");
try
{
input.close();
}
catch (IOException e)
{
System.out.println("Fermeture entrée client : " + e.getMessage() );
}
Socket socket = (Socket) streams.get("socket");
try
{
socket.close();
}
catch (IOException e)
{
System.out.println("Fermeture socket client : " + e.getMessage() );
}
}
}
private synchronized void removeClient(String key)
{
//Suppression du client de la liste
clients.remove(key);
} |
Partager