made client extend thread so a new connection can be launched when the game is started

This commit is contained in:
Sem van der Hoeven
2020-05-11 11:55:32 +02:00
parent 615273f301
commit f9c0a4834e
2 changed files with 5 additions and 6 deletions

View File

@@ -6,15 +6,14 @@ import java.io.IOException;
import java.net.Socket;
import java.util.Scanner;
public class Client {
public class Client extends Thread{
private int port;
private String hostname;
private boolean isConnected = true;
public static void main(String[] args) {
Client client = new Client("localhost",8000);
client.connect();
@Override
public void run() {
this.connect();
}
public Client(String hostname, int port) {

View File

@@ -15,7 +15,7 @@ import java.util.HashMap;
public class Server {
private ServerSocket serverSocket;
private static final int PORT = 8000;
public static final int PORT = 8000;
private ArrayList<ServerClient> clients = new ArrayList<>();
private HashMap<String, Thread> clientThreads = new HashMap<>();