This commit is contained in:
28
app/src/main/java/network/server/Server.java
Normal file
28
app/src/main/java/network/server/Server.java
Normal file
@@ -0,0 +1,28 @@
|
||||
package network.server;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.ServerSocket;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Server {
|
||||
|
||||
final ServerSocket serverSocket;
|
||||
final List<ServerConnexion> connexions;
|
||||
private final ServerThread thread;
|
||||
|
||||
public Server(short port) throws IOException {
|
||||
this.serverSocket = new ServerSocket(port);
|
||||
this.connexions = new ArrayList<>();
|
||||
this.thread = new ServerThread(this);
|
||||
this.thread.start();
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
this.thread.cancel();
|
||||
for (ServerConnexion connexion : this.connexions) {
|
||||
connexion.close();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user