Commit 6dfd5c4a authored by bogdanbear's avatar bogdanbear

Debugging restart bug.

parent d2636435
......@@ -51,7 +51,7 @@ public class GameContent implements Serializable{
* Relayer dmr = Relayers.addNewRelayer(2,AItest,this);
* AIControler.add(gameContent,dmr);
*/
System.out.println("One gameContent created");
System.out.println("GameContent class: One gameContent created");
}
public Map getMap() {
......
......@@ -23,10 +23,9 @@ public class GameStarter {
static public void startGameSinglePlayer()
{
NetworkConnection<NetworkObject>[] localConnections= LocalConnection.initiate();
NetworkConnection<NetworkObject>[] localConnections= LocalConnection.createNew();
NetworkConnection<NetworkObject> serverConnection = localConnections[0];
NetworkConnection<NetworkObject> clientConnection = localConnections[1];
ServerLoop dummyServerLoop=new ServerLoop(serverConnection);
DummyLocalGameLoop.getInstance().setNetworkConnection(clientConnection);
......@@ -36,6 +35,7 @@ public class GameStarter {
if (!DummyLocalGameLoop.getInstance().startedBefore())
DummyLocalGameLoop.getInstance().start();
//this is start and not run like in the DummyServer, because here we are dealing with a thread
ServerLoop dummyServerLoop=new ServerLoop(serverConnection);
dummyServerLoop.start();
//let the loop run now!
DummyLocalGameLoop.getInstance().startGame();
......
......@@ -84,7 +84,7 @@ public class LocalConnection<E extends NetworkObject> extends NetworkConnection<
* Will create two objects LocalConnection : one for the server part and one for the client part.
* @return the two LocalConnection, the first is the server one and the second is the client one.
*/
public static NetworkConnection<NetworkObject>[] initiate() {
public static NetworkConnection<NetworkObject>[] createNew() {
LocalConnection<NetworkObject>[] bothConnections = new LocalConnection[2];
BlockingDeque<NetworkObject> incomingForServer = new LinkedBlockingDeque<>();
BlockingDeque<NetworkObject> incomingForClient = new LinkedBlockingDeque<>();
......
......@@ -11,14 +11,14 @@ import static org.junit.Assert.assertEquals;
/**
* Class for JUnits Test for the class LocalConnection.
* Created by mymi on 19/12/15.
* To begin, we use LocalConnection.initiate() to create a server and a client.
* To begin, we use LocalConnection.createNew() to create a server and a client.
* Then we test sendEvent on the server side and receiveEvent on the client side.
* The second function will do the opposite.
* Finally, we will test initiateConnectionEnd (TODO)
*/
@SuppressWarnings("unchecked")
public class LocalConnectionTest{
NetworkConnection[] localConnections= LocalConnection.initiate();
NetworkConnection[] localConnections= LocalConnection.createNew();
private NetworkConnection serverConnection = localConnections[0];
private NetworkConnection clientConnection = localConnections[1];
private NetworkObject event = new ObjectForTest();
......
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