Skip to content
Snippets Groups Projects
Commit 6800cfd7 authored by Elrabu's avatar Elrabu
Browse files

eb093: fixed: fixed multiplayer branch

parent fa1b5881
No related branches found
Tags v0.2.0
5 merge requests!74V1,!73Initial commit,!71Merge DataBase into Development,!54Update: coreMaps.json (added new maps),!39Merge Request
......@@ -33,39 +33,29 @@ public class Server {
private static int[] cords;
private static int[] returncords = {enemyx,enemyy,playerID,enemyAttacking,enemyClass,enemyWalkDirection,enemyHealth};
private boolean started = false;
private static String ipaddress = "localhost";
//Uncomment these lines to test the server starting manually:
/* public static void main(String[] args) throws IOException { //main method for testing purposes
Server server = new Server();
log.info("server starting...");
server.start( 4444);
}
server.start(ipaddress, 4444);
} */
//use this method to start the server from another class
public void startServer() throws IOException {
public void startServer() throws IOException {
Server server = new Server();
log.info("server starting...");
server.start(ipaddress,4444);
}
public void start(int port) throws IOException {
public void start(String host_ip, int port) throws IOException {
serverSocket = new ServerSocket(port);
log.info("server started!");
started = true;
log.info("server accepting Thread starting...");
Thread serverThread = new Thread(() -> {
while (true) {
try {
new ServerHandler(serverSocket.accept()).start();
} catch (IOException e) {
e.printStackTrace();
}
}
});
serverThread.start();
log.info("requests accepting Thread started!");
while (true){
new ServerHandler(serverSocket.accept()).start();
}
}
private static class ServerHandler extends Thread {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment