Commit 7fd4ca9c authored by Bogdan's avatar Bogdan

Some minor modifications...

parent 4a24d57a
......@@ -57,7 +57,7 @@ public class ServerAddressPanel extends MenuPanel{
private ActionListener serverButtonActionListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent actionEvent) {
RPCServer.main();
RPCServer.startServer();
getGraphicsMaster().changeGUIStateTo(GraphicsMaster.GUIStates.SERVER_CREATED_PANEL);
}
};
......
......@@ -8,7 +8,7 @@ import network.outershell.Lounge;
/**
* Created by bogdanbear on 20/11/2015.
*/
public class LoungeServer {
public class LoungeServer extends Thread {
private Lounge lounge;
private int numberOfPlayers;
public LoungeServer(Lounge lounge, int numberOfPlayers)
......@@ -16,12 +16,27 @@ public class LoungeServer {
this.lounge=lounge;
this.numberOfPlayers=numberOfPlayers;
}
public void initiateServer()
@Override
public void run()
{
ServerConnection serverConnection=new ServerConnection(lounge.getPort(),0, true,lounge.MAX_PLAYERS);
Logging.getInstance().getLogger().info("Server started second phase, initialization done");
ServerLoop dummyServerLoop=new ServerLoop(serverConnection);
dummyServerLoop.start();
notifyOnIt();
}
public synchronized void notifyOnIt()
{
notify();
}
public synchronized void waitOnIt()
{
try {
wait();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
......@@ -14,7 +14,7 @@ import java.util.logging.Logger;
public class RPCServer {
public static int scale=25;
private static Logger LOGGER = Logging.getInstance().getLogger();
public static void main()
public static void startServer()
{
try {
LocateRegistry.createRegistry(1099);
......@@ -24,5 +24,9 @@ public class RPCServer {
LOGGER.warning("RPCServer: Server failed: " + e);
}
}
public static void main(String[] arguments)
{
startServer();
}
}
......@@ -67,7 +67,8 @@ public class Registrar extends UnicastRemoteObject implements RegisterInterface
waiting.put(genID, lounge);
//instantiate a loungeServer on the serverside and then put it into motion
LoungeServer loungeServer=new LoungeServer(lounge,lounge.MAX_PLAYERS);
loungeServer.initiateServer();
loungeServer.start();
loungeServer.waitOnIt();
//after obtaining the genID the host will immediately launch joinGame
return lounge;
......
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