Merge remote-tracking branch 'origin/master'

# Conflicts:
#	src/main/java/ch/unibas/dmi/dbis/cs108/gamelogic/Game.java
#	src/main/java/ch/unibas/dmi/dbis/cs108/multiplayer/client/gui/chat/ChatApp.java
This commit is contained in:
Jonas 2022-04-18 22:42:09 +02:00
commit 814eed9442
23 changed files with 279 additions and 75 deletions

View File

@ -115,12 +115,12 @@ Allerdings werden die Nachrichten noch als einfacher String übermittelt und noc
Wer macht Was?
Seraina: bis 25.4 Abends
Seraina: bis 25.3 Abends
• QA-Concept
• Fortfahren mit Spiellogik
Sebastian: bis 25.4 Abends
Sebastian: bis 25.3 Abends
Protocol
• Formatter /Parser(Namingconvention überlegen)
o Format: COMND$parameter(i.e. Name)$parameter(i.e. msg)
@ -130,7 +130,7 @@ Protocol
• Enum: All Legal Protocol Commands
Jonas: bis 25.4 Abends
Jonas: bis 25.3 Abends
• PingPong-Funktionalität
o PingPong handler
o Every two seconds (what is the standard?)
@ -142,7 +142,7 @@ Jonas: bis 25.4 Abends
o assign Ip (maybe port) method ?
Alexandr: bis 26.4 Abends
Alexandr: bis 26.3 Abends
• Automatic username assignment
• Username duplicate handler
o Login -> username? -> check -> username01
@ -155,7 +155,7 @@ Alexandr: bis 26.4 Abends
Rule: Alles was geht in eigene Klassen Methoden schreiben.
Soviel wie möglich commiten mit Aufschlussreichen messages.
Nächste Absprache Fr 25.4 Abends
Nächste Absprache Fr 25.3 Abends
@ -266,7 +266,8 @@ Stand 17:30 Uhr:
auf Integration in einen grösseres GUI-Modul. Wir werden wohl JavaFX(openFX) verwenden.
ToDo:
Spiellogik: - Send() methode von Passenger mit Client-Server verknüpfen(Seraina)
Spiellogik:
- Send() methode von Passenger mit Client-Server verknüpfen(Seraina)
- NoiseHandler (Alex)
- Game Zyklus implementieren (Seraina)
@ -275,9 +276,47 @@ ToDo:
- Implementierung NoiseHandler, Verbindung mit VoteHandler
- Verbesserung der Lesbarkeit von VoteHandler (Code-Duplikate in eine Methode zusammengefasst)
11.04.2022 - Seraina
Spiellogik: Es besteht eine basale Verknüpfung zwischen Client-Server und Spiellogik. Ein Client kann
eine Stimme abgeben und sie wird gezählt, NPC können sehr stupide stimmen abgegen (randomisiert). Der
Server schickt dem Client bei einem Voterequest immer seine Position im Zug mit, und der client schickt
sie dem Server wieder zurück.
13.04.2022 - Seraina
Spiellogik: Habe Alexs noiseHandling in die restliche Spiellogik integriert und debugged. Ebenso musste
ich den Input der Clients beim Abstimmen geben umstrukturieren. Anstatt dass eine speziefische Methode
für das Voting aufgerufen wird, wird über ein Befehl '/v vote' gemacht der über die gleichen Kanäle geht
wie alle anderen Konsolenbefehle.
TODO: Vote enforcement von Serverseite. Momentan können Humans in der Nacht und umgekehrt reinfunken und
ihre Stimmen werden gezählt.
14.04.2022 - Alex
- Erste Version des Spiel-Manuals
14.04.2022 - Jonas, Seraina, Sebi, Alex
Integration von Lobby und gamelogic.
15.04.2022 - Seraina
Die Spiellogik läuft nun mit Enforcment. Geister und Menschen können nur zu enstprechender Zeit voten,
sonst werden ihre stimmen einfach nicht gewertet. Geister, die schon vom Zug geflogen sind, können nun
auch nicht mehr mitspielen. Habe eine Spectator Klasse hinzugefügt für Spieler, die aus dem Spiel geflogen
sind.
16.04.2022 - Seraina, Sebi
Es gibt ein Problem mit der Gui, irgendwie funktioniert die Verbindung von Application Klasse zu
fxlm file nicht.
17.04.2022 - Seraina, Sebi
GUI-Troubleshooting: wir haben das Problem mit der GUI lokalisiert, es wird beim launch einer Application
immer nur ein Objekt der Klasse erstellt, und zwar mit Konstruktor ohne Parametern. Um Parameter zu übergeben,
müssen statische Felder und definiert und diese nach launch und Initialisierung (beim Controller) mittels
Setter übergeben werden.
17.04.2022 - Sebastian
- Dank Sereina kommuniziert die GUI nun mit dem Client und Nachrichten kommen korrekt an und werden korrekt verschickt.
- Dank Seraina kommuniziert die GUI nun mit dem Client und Nachrichten kommen korrekt an und werden korrekt verschickt.
Im GUI funktioniert der Whisper nun. Folgendes Colorcoding: Eigene Nachrichten sind Lavendelfarben. Normale Chat nachrichten blau,
und im Momentan Whisper Nachrichten violet.
18.04.2022 - Seraina
Nach etlichem lesen von Websites zu custom tasks in gradle habe ich entlich die build-cs108 task zum Laufen
gebracht. Es war wie so oft die einfachste Lösung.

View File

@ -0,0 +1,163 @@
GENERAL INFORMATION: _______________________________________________________________________________________________
Protocol messages should always start with five characters (these are the Strings listed here).
If additional information is necessary, it should be given after a dollar sign, as such: PRTCL$information.
It should be noted that the server simply ignores the 6th character, however for clarity's sake it should always
be a $. If more than one piece of information needs to be sent, the separate pieces of information should also be
delimited with a dollar sign (see whisper for an example). In that case, it is very important that it is a $ and
nothing else. Also, in such cases, we need to make sure the pieces of information between the $ do not contain $
themselves (for example, usernames cannot contain $).
____________________________________________________________________________________________________________________
The five-character Strings that define protocol messages are all defined as String variables in the Protocol.java
class. In this document, they are depicted as such:
nameOfStringVariable = "EXMPL"
EXMPL$information one$information two
Documentation of Protocol message
So "EXMPL" is the actual protocol message being sent, however the code never implements this five-character String
directly but instead accesses it via Protocol.nameOfStringVariable, so the actual protocol message can be changed
later.
The second line, if present, shows an example of how the Syntax of the protocol message works, if the protocol
message is sent with additional arguments.
Indented is the actual documentation, which explains what the protocol message does.
BIDIRECTIONAL COMMANDS: ____________________________________________________________________________________________
pingBack = "PINGB"
Ping-back message from client to server / server to client. To be sent upon receiving "CPING" / "SPING".
The other party then registers this in its ClientPinger / ServerPinger thread.
CLIENT TO SERVER COMMANDS: _________________________________________________________________________________________
chatMsgToAll = "CHATA"
CHATA$Chat message
When the server receives this, it broadcasts a chat message to all clients. The message has to be given in the
protocol message after CHATA$, for example the protocol message CHATA$Hello everybody!, if sent from the user
named Poirot, will print Poirot: Hello everybody! to every connected client's chat console (note the absence
/ presence of spaces).
chatMsgToLobby = "CHATL"
CHATL$Chat message
When the server receives this, it broadcasts a chat message to all clients in the same Lobby. The message has to be
given in the protocol message after CHATL$, for example the protocol message CHATL$Hello everybody!, if sent from
the user named Poirot, will print Poirot: Hello everybody! to the chat console of every client in the lobby (note
the absence / presence of spaces). If the client is not in a lobby, the chat message will be sent to everyone not
in a lobby.
clientLogin = "LOGIN"
LOGIN$username
The message sent by the client on login to set their name. For example, LOGIN$Poirot will use the
clientHandler.setUsernameOnLogin() method to set this client's username to Poirot, and broadcast the announcement:
"Poirot has joined the Server". Also, it will set this clientHandler's loggedIn boolean to true, which could be
used later to refuse access to users who haven't formally logged in using this command.
nameChange = "NAMEC"
NAMEC$new name
Client requests their name to be changed to whatever follows NAMEC$. For example, NAMEC$Poirot means the client
wants to change their name to Poirot. However, the server will first pass this name through
nameDuplicateChecker.checkName() to adjust it as needed (remove : and $ and add suffix in case of duplicate name.)
pingFromClient = "CPING"
Client sends ping message to server. If the client doesn't recieve a pingback from the server, it shows a
disconnection message and sets clientPinger.isConnected to false, which can be implemented somehow later.
As soon as a pingback message is received, isConnected is set to true again and a reconnection message is printed.
clientQuitRequest = "QUITR"
The client requests to quit. Once the server receives this message, it will send a serverConfirmQuit message to the
client to confirm the quitting, then close the socket associated with that client and remove the clientHandler from
the list of clientHandlers.
createNewLobby = "CRTLB"
Client sends this message when they want to create a new lobby (& automatically join it). Client issues this
command in ch.unibas.dmi.dbis.cs108.multiplayer.client.MessageFormatter using "/g". First a lobby Lobby is created
of which the requesting client is the admin of.
listLobbies = "LISTL"
Represents a clients' request for a list of lobbies, plus what players are in them.
listPlayersInLobby = "LISTP"
Represents a clients' request for a list of all players within the lobby.
joinLobby = "JOINL"
JOINL$int
Client requests to join the Lobby with the given number, for example,
JOINL$2 means the client wants to join lobby 2.
leaveLobby = "LEAVL"
Client requests to leave whatever lobby they're in.
whisper = "WHISP"
WHISP$recipient's username$message
Whisper chat.
startANewGame = "STGAM"
A Client (lobby admin) decides to start the game. The game is started in the lobby the message came from.
Only one game can be started per lobby at a time.
listGames = "LISTG"
Client request to see a list of all games, ongoing and finished.
votedFor = "CVOTE"
CVOTE$position$vote
Client informs server that they have voted and delivers this vote in the form of "CVOTE$position$vote"
SERVER TO CLIENT COMMANDS: _________________________________________________________________________________________
pingFromServer = "SPING"
Server sends ping message to client. If the server doesn't recieve a pingback from the client, it shows a
disconnection message and sets serverPinger.isConnected to false, which can be implemented somehow later.
As soon as a pingback message is received, isConnected is set to true again and a reconnection message is printed.
printToClientConsole = "CONSM"
CONSM$message
prints out incoming announcements into the user's console. any string that follows CONSM$ is printed as is, so the
message that follows already has to be formatted the way it should be shown to the client.
printToClientChat = "CHATM"
CHATM$message
prints out incoming chat messages into the user's chat. any string that follows CHATM$ is printed as is, so the
message that follows already has to be formatted the way it should be shown to the client.
serverConfirmQuit = "QUITC"
Server confirms the client's quit request, meaning that the client can now close its sockets and quit.
serverRequestsGhostVote = "GVOTR"
GVOTR$passenger position (int)$train information
The server requests the client (who should be a ghost) to vote on the victim. in the format
GVOTR$string the current train will be shown as a string to the client
serverRequestsHumanVote = "HVOTR"
HVOTR$passenger position (int)$train information
The server requests the client (who should be a human) to vote on who is a ghost / who should be kicked
off the train.
changedUserName = "CHNAM"
CHNAM$newname
Informs Client that their username has been changed.

View File

@ -8,7 +8,7 @@ import org.apache.logging.log4j.core.config.Configuration;
import org.apache.logging.log4j.core.config.LoggerConfig;
/**
*
*A Class that lets us set the RootLogger Level of all Classes in this Project
*/
public class BudaLogConfig {

View File

@ -7,6 +7,11 @@ import java.net.InetAddress;
public class NightTrainToBudapest {
/**
* The main Method of the jar build of this project. calls either the main method of the server or
* the main method of the client
* @param args the arguments are either client {@code <hostadress>:<port> [<username>] or server <port>}
*/
public static void main(String[] args) {
try {
String clientOrServer = args[0];

View File

@ -1,6 +1,5 @@
package ch.unibas.dmi.dbis.cs108.gamelogic;
import ch.unibas.dmi.dbis.cs108.gamelogic.klassenstruktur.Passenger;
/**
* Handles all communication Client to Server concerning gamestate updates i.e. client a has voted

View File

@ -81,7 +81,7 @@ public class Game implements Runnable {
LOGGER.info(gameState.toString());
for (ClientHandler client : lobbyClients) {
for (ClientHandler client : lobbyClients) {//begins filling the train with clients
int index = order[i];
if (passengerTrain[index].getIsGhost()) { //if there is a ghost
GhostPlayer ghostPlayer = new GhostPlayer(passengerTrain[index].getPosition(),
@ -94,7 +94,7 @@ public class Game implements Runnable {
}
i++;
}
while (i < order.length) {
while (i < order.length) {//fills the rest of the train with npcs
int index = order[i];
if (passengerTrain[index].getIsGhost()) { //if they are a ghost
GhostNPC ghostNPC = new GhostNPC(passengerTrain[index].getPosition(), "NPC" + passengerTrain[index].getPosition(),passengerTrain[index].getIsOG());
@ -109,7 +109,7 @@ public class Game implements Runnable {
LOGGER.info(gameState.toString());
i = 0;
while (isOngoing) {
while (isOngoing) {//game cycle
if (!isDay) {
LOGGER.info("NIGHT");
gameOverCheck = voteHandler.ghostVote(gameState.getPassengerTrain(), this);

View File

@ -7,8 +7,6 @@ import ch.unibas.dmi.dbis.cs108.gamelogic.klassenstruktur.Human;
import ch.unibas.dmi.dbis.cs108.gamelogic.klassenstruktur.HumanNPC;
import ch.unibas.dmi.dbis.cs108.gamelogic.klassenstruktur.Passenger;
import ch.unibas.dmi.dbis.cs108.multiplayer.server.ClientHandler;
import java.util.Arrays;
import java.util.HashSet;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

View File

@ -1,6 +1,6 @@
package ch.unibas.dmi.dbis.cs108.gamelogic;
import ch.unibas.dmi.dbis.cs108.gamelogic.klassenstruktur.Ghost;
import ch.unibas.dmi.dbis.cs108.gamelogic.klassenstruktur.Passenger;
/**

View File

@ -1,12 +1,10 @@
package ch.unibas.dmi.dbis.cs108.gamelogic;
import ch.unibas.dmi.dbis.cs108.BudaLogConfig;
import ch.unibas.dmi.dbis.cs108.gamelogic.klassenstruktur.Ghost;
import ch.unibas.dmi.dbis.cs108.gamelogic.klassenstruktur.GhostNPC;
import ch.unibas.dmi.dbis.cs108.gamelogic.klassenstruktur.HumanNPC;
import ch.unibas.dmi.dbis.cs108.gamelogic.klassenstruktur.Passenger;
import ch.unibas.dmi.dbis.cs108.multiplayer.helpers.Protocol;
import ch.unibas.dmi.dbis.cs108.multiplayer.server.ClientHandler;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

View File

@ -75,8 +75,5 @@ public class Train {
return false;
}
public static void main(String[] args) {
System.out.println("Hallo");
}
}

View File

@ -1,7 +1,6 @@
package ch.unibas.dmi.dbis.cs108.gamelogic;
import ch.unibas.dmi.dbis.cs108.BudaLogConfig;
import ch.unibas.dmi.dbis.cs108.gamelogic.klassenstruktur.Ghost;
import ch.unibas.dmi.dbis.cs108.gamelogic.klassenstruktur.Passenger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@ -51,8 +50,8 @@ public class VoteHandler {
}
}
try { // waits 20 seconds before votes get collected
Thread.sleep(60*1000);
try { // waits 30 seconds before votes get collected
Thread.sleep(30*1000);
} catch (InterruptedException e) {
LOGGER.warn("Thread " + Thread.currentThread() + " was interrupted");
}
@ -143,7 +142,7 @@ public class VoteHandler {
}
}
try { // waits 20 seconds before votes get collected
try { // waits 60 seconds before votes get collected
Thread.sleep(60*1000);
} catch (InterruptedException e) {
LOGGER.warn("Thread " + Thread.currentThread() + " was interrupted");

View File

@ -1,7 +1,6 @@
package ch.unibas.dmi.dbis.cs108.gamelogic.klassenstruktur;
import ch.unibas.dmi.dbis.cs108.BudaLogConfig;
import ch.unibas.dmi.dbis.cs108.gamelogic.Game;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

View File

@ -2,9 +2,7 @@ package ch.unibas.dmi.dbis.cs108.gamelogic.klassenstruktur;
import ch.unibas.dmi.dbis.cs108.BudaLogConfig;
import ch.unibas.dmi.dbis.cs108.gamelogic.Game;
import ch.unibas.dmi.dbis.cs108.gamelogic.GameState;
import ch.unibas.dmi.dbis.cs108.gamelogic.ServerGameInfoHandler;
import ch.unibas.dmi.dbis.cs108.gamelogic.TrainOverflow;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@ -77,10 +75,4 @@ public class GhostNPC extends Ghost {
}
}
/**
* Decides what to do when a noise ist heard, currently just always broadcasts it
* TODO: Make NPC smarter
*/
}

View File

@ -1,7 +1,6 @@
package ch.unibas.dmi.dbis.cs108.gamelogic.klassenstruktur;
import ch.unibas.dmi.dbis.cs108.BudaLogConfig;
import ch.unibas.dmi.dbis.cs108.gamelogic.Game;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

View File

@ -3,7 +3,6 @@ package ch.unibas.dmi.dbis.cs108.gamelogic.klassenstruktur;
import ch.unibas.dmi.dbis.cs108.BudaLogConfig;
import ch.unibas.dmi.dbis.cs108.gamelogic.Game;
import ch.unibas.dmi.dbis.cs108.gamelogic.ServerGameInfoHandler;
import ch.unibas.dmi.dbis.cs108.multiplayer.server.ClientHandler;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@ -23,7 +22,11 @@ public class Spectator extends Passenger{
isSpectator = true;
}
/**
* Sends a message to the Client assosiated with this Spectator via ServerGameInfoHandler.spectatorFormat
* @param msg the message that is sent to this player.
* @param game the game the Passenger lives on
*/
@Override
public void send(String msg, Game game) {
clientHandler.sendMsgToClient(ServerGameInfoHandler.spectatorFormat(msg, this, game));

View File

@ -62,7 +62,6 @@ public class Client {
sendMsgToServer(Protocol.clientLogin + "$" + systemName);
this.chatApp = new ChatApp(new ClientModel(systemName, this));
this.chatGui = new GUI(this.chatApp);
chatGui.setName(systemName);
clientPinger = new ClientPinger(this, this.socket);
} catch (IOException e) {
e.printStackTrace();
@ -205,6 +204,10 @@ public class Client {
}
}
/**
* The main Method used for testing in IDE
* @param args not used in this main
*/
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String hostname;
@ -239,6 +242,12 @@ public class Client {
}
/**
* The main-method used for the jar build of this project
* @param address the IP address of the Server (can be localhost)
* @param port the port for the connection
* @param username the username of this client
*/
public static void main(InetAddress address, int port, String username) {
Scanner sc = new Scanner(System.in);
Socket socket;

View File

@ -31,7 +31,6 @@ public class JClientProtocolParser {
}
switch (header) {
case Protocol.pingFromServer:
c.sendMsgToServer(Protocol.pingBack);
break;
case Protocol.pingBack:

View File

@ -11,16 +11,13 @@ public class GUI implements Runnable {
public static final Logger LOGGER = LogManager.getLogger(GUI.class);
public static final BudaLogConfig l = new BudaLogConfig(LOGGER);
ChatApp chatApp;
private String name;
private ChatApp chatApp;
public GUI(ChatApp chatApp) {
this.chatApp = chatApp;
}
public void setName(String name) {
this.name = name;
}
/**
* When an object implementing interface {@code Runnable} is used to create a thread, starting the
@ -32,11 +29,9 @@ public class GUI implements Runnable {
* @see Thread#run()
*/
@Override
public void run() {
LOGGER.info("here");
//String name =
Application.launch(this.chatApp.getClass());
}
}

View File

@ -1,7 +1,6 @@
package ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.chat;
import ch.unibas.dmi.dbis.cs108.BudaLogConfig;
import ch.unibas.dmi.dbis.cs108.multiplayer.client.Client;
import ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.ClientModel;
import java.net.URL;
import java.util.Objects;
@ -25,19 +24,28 @@ public class ChatApp extends Application {
public ChatApp() {
super();
LOGGER.info("Empty ChatApp constructor got called: ");
}
public ChatApp(ClientModel clientModel) {
this.clientModel = clientModel;
this.chatController = new ChatController(clientModel);
public ChatApp(ClientModel clientM) {
clientModel = clientM;
chatController = new ChatController(clientM);
}
public static void setChatController(
ChatController chatC) {
/**
* Sets the ChatController for the Application, needs to be static, but only one application can
* be launched per programm
*
* @param chatC the ChatController to be linked to this chatApp
*/
public static void setChatController(ChatController chatC) {
chatController = chatC;
}
/**
* Sets the non-static ClientModel field of this class
*
* @param cModel the non static ClientModel to be added
*/
public void setcModel(ClientModel cModel) {
this.cModel = cModel;
}
@ -54,6 +62,11 @@ public class ChatApp extends Application {
return clientModel;
}
public ChatController getChatController() {
return chatController;
}
/**
* The main entry point for all JavaFX applications. The start method is called after the init
* method has returned, and after the system is ready for the application to begin running.
@ -69,11 +82,9 @@ public class ChatApp extends Application {
*/
@Override
public void start(Stage primaryStage) throws Exception {
LOGGER.info("made it here");
this.setcModel(clientModel);
URL resource = ChatApp.class.getResource(
"splitPaneChatView.fxml");
LOGGER.info("1");
if (resource == null) {
System.out.println("File wasnt found");
}
@ -82,23 +93,16 @@ public class ChatApp extends Application {
Parent root = FXMLLoader.load(
Objects.requireNonNull(ChatApp.class.getResource(
"splitPaneChatView.fxml")));
LOGGER.info("2");
// TODO bin chatController.getChatPaneRoot() border to root border for resizing
// TODO bin chatController.getChatPaneRoot() border to root border for rezising
Scene scene = new Scene(root);
LOGGER.info("3");
scene.setRoot(root);
LOGGER.info("4");
primaryStage.setScene(scene);
LOGGER.info("5");
} catch (Exception e) {
e.printStackTrace();
}
primaryStage.setResizable(true);
LOGGER.info("6");
primaryStage.setTitle("Chat");
LOGGER.info("7");
primaryStage.show();
LOGGER.info("8");
}
@ -107,7 +111,4 @@ public class ChatApp extends Application {
launch(args);
}
public ChatController getChatController() {
return chatController;
}
}

View File

@ -22,7 +22,6 @@ import javafx.scene.control.SplitPane;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;
import javafx.scene.layout.Background;
import javafx.scene.layout.BackgroundFill;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import org.apache.logging.log4j.LogManager;
@ -53,7 +52,10 @@ public class ChatController implements Initializable {
private static final String chatToAll = Protocol.chatMsgToAll;
private static final String chatToLobby = Protocol.chatMsgToLobby;
public ChatController() { //TODO: why does this get called
/**
* Needs to stay, because it gets called in initialisation
*/
public ChatController() {
super();
whisperTargetChosen = new SimpleBooleanProperty();
cmd = Protocol.chatMsgToLobby + "$";
@ -154,13 +156,15 @@ public class ChatController implements Initializable {
}
/**
* @return the client who's chat controller this is
* @return the ClientModel whose chat controller this is
*/
public static ClientModel getClient() {
return client;
}
/**
* Sets the ClientModel of this ChatController
*
* @param client who's gui controller this should be
*/
public void setClient(ClientModel client) {
@ -172,7 +176,7 @@ public class ChatController implements Initializable {
}
/**
* The client calls this method to foreward a chat message to the chat gui
* The client calls this method to forward a chat message to the chat gui
*
* @param msg the message to be displayed
*/

View File

@ -3,7 +3,6 @@ package ch.unibas.dmi.dbis.cs108.multiplayer.helpers;
import ch.unibas.dmi.dbis.cs108.BudaLogConfig;
import ch.unibas.dmi.dbis.cs108.multiplayer.server.ClientHandler;
import java.io.BufferedWriter;
import java.io.IOException;
import java.net.Socket;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

View File

@ -2,11 +2,6 @@ package ch.unibas.dmi.dbis.cs108.multiplayer.server;
import ch.unibas.dmi.dbis.cs108.BudaLogConfig;
import ch.unibas.dmi.dbis.cs108.gamelogic.ClientVoteData;
import ch.unibas.dmi.dbis.cs108.gamelogic.Game;
import ch.unibas.dmi.dbis.cs108.gamelogic.GameState;
import ch.unibas.dmi.dbis.cs108.gamelogic.TrainOverflow;
import ch.unibas.dmi.dbis.cs108.gamelogic.VoteHandler;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import ch.unibas.dmi.dbis.cs108.multiplayer.helpers.Protocol;

View File

@ -43,6 +43,9 @@ public class Server {
}
}
/**
* closes the Server socket of this server
*/
public void closeServerSocket() {
try {
if (serverSocket != null) {
@ -53,6 +56,10 @@ public class Server {
}
}
/**
* The main method used for testing
* @param args not used in this method
*/
public static void main(String[] args) {
ServerSocket serverSocket = null;
gamePort = 1873;
@ -65,6 +72,10 @@ public class Server {
server.startServer();
}
/**
* The main method of the Server that is used for the jar build of this project
* @param port the port the server will open on
*/
public static void main(int port) {
gamePort = port;
ServerSocket serverSocket = null;