Commit 6bda3207 authored by Bogdan's avatar Bogdan

Code cleanup for some network classes.

parent d9982357
......@@ -32,9 +32,6 @@ public class ClientConnection extends NetworkConnection{
//the id of this thread is not important, since it is on the client side.
ClientInputThread clientInputThread = new ClientInputThread(socket, this,false,0);
clientInputThread.start();
//catch (IOException e) {
// System.out.println("network: IO excception thrown in ClientConnection.close(), could also be a case of UnknownHostException");
//}
LOGGER.info("ClientConnection initialized");
}
catch (IOException e)
......@@ -83,14 +80,6 @@ public class ClientConnection extends NetworkConnection{
} catch (IOException e) {
LOGGER.warning(e.toString());
}
// try {
// if (outputStream!=null)
// outputStream.close();
// if (socket != null)
// socket.close();
// } catch (IOException e) {
// System.out.println("network: IO excception thrown in ClientConnection.close()");
// }
}
......
......@@ -68,10 +68,9 @@ public class ClientOutputThread extends Thread{
} catch (IOException e1) {
LOGGER.warning("ClientInputThread - IOException");
//parent.setBroken(true);
//parent.setBroken(true); cannot do this because we do not know whether this is a client of server thread
} finally {
LOGGER.info("ClientOutputThread dying");
//parent.setBroken(true);
try {
socket.close();
} catch (IOException e1) {
......
......@@ -61,7 +61,6 @@ public class LocalConnection extends NetworkConnection {
/**
* receiveEvent for the client part
*
* @param blocking true if the queue is in blocking mode
* @return a new event
*/
......
......@@ -28,10 +28,8 @@ public class ServerConnection extends NetworkConnection{
* this parameter gives the maximum number of clients allowed to join late
*/
private int maxNumberOfLateClients;
//this blocking deque stores all the events received from the clients, in a consistent order
//TODO uses the two following variable
//this blocking deque stores all the events received from the clients, in a consistent order
private BlockingDeque<NetworkObject> incomingEvents=new LinkedBlockingDeque<>();
//a list of outgoing client threads
private ArrayList<ClientOutputThread> outputThreads=new ArrayList<>();
......@@ -46,26 +44,21 @@ public class ServerConnection extends NetworkConnection{
{
outputThreads.add(thread);
}
public synchronized boolean isStillRunning() {
return stillRunning;
}
public synchronized void setStillRunning(boolean stillRunning) {
this.stillRunning = stillRunning;
}
public int getMaxNumberOfLateClients() {
return maxNumberOfLateClients;
}
/**
* @return the object which will be notifed when the serverconnection becomes ready
* the following class was part of an attempt to allow client to join after the game has started
* the network part works fine, in order to finish this implementation we also need to modify the mapinit system
* slightly, in the sense that we need to add MapRequest events
*/
public Waitable getToNotify() {
return toNotify;
}
private class ServerListeningThread extends Thread{
private ServerConnection parent;
private ServerSocket listeningSocket;
......@@ -207,7 +200,6 @@ public class ServerConnection extends NetworkConnection{
}
}
/**
* maybe this will not be needed
* return whether there exists at least a thread that is alive
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment