What am I doing...

This commit is contained in:
Sebastian Lenzlinger 2022-03-21 20:44:51 +01:00
parent 371efdf89c
commit 4fcd68fef5
2 changed files with 11 additions and 3 deletions

View File

@ -0,0 +1,4 @@
package ch.unibas.dmi.dbis.cs108.Multiplayer.Server;
public class ClientHandler {
}

View File

@ -3,18 +3,22 @@ package ch.unibas.dmi.dbis.cs108.Multiplayer.Server;
import java.io.IOException; import java.io.IOException;
import java.net.ServerSocket; import java.net.ServerSocket;
import java.net.Socket; import java.net.Socket;
import java.util.HashMap;
public class Server { public class Server {
int port = 42069; private static final int gamePort = 42069;
private static int clientIndex = 0;
private HashMap<String, Integer> nameToIndex = new HashMap<>();
private HashMap<Integer, ClientHandler> indexToHandler = new HashMap<>();
public static void main(String[] args) { public static void main(String[] args) {
try { try {
ServerSocket gameServer = new ServerSocket(42069); ServerSocket gameServer = new ServerSocket(gamePort);
System.out.println("Waiting for a connection on Port 42069"); System.out.println("Waiting for a connection on Port 42069");
while(true) { while(true) {
Socket connector = gameServer.accept(); Socket client = gameServer.accept();
} }
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();