fixed Method Initializing. Setting Datafields serverAddress and serverPort.

#24
This commit is contained in:
schrom01 2022-04-15 01:26:24 +02:00
parent a75d3466ef
commit bc86c47871
1 changed files with 9 additions and 2 deletions

View File

@ -34,9 +34,16 @@ public class ClientConnectionHandler extends ConnectionHandler implements Runnab
} }
public void initialize(String serverAddress, int serverPort, String userName) throws IOException { public void initialize(String serverAddress, int serverPort, String userName) throws IOException {
state = new SimpleObjectProperty<>(NEW); this.state = new SimpleObjectProperty<>(NEW);
setConnection(NetworkHandler.openConnection(serverAddress, serverPort)); this.serverAddress = new SimpleStringProperty(serverAddress);
this.serverPort = new SimpleIntegerProperty(serverPort);
this.userName = new SimpleStringProperty((userName == null || userName.isBlank())? USER_NONE : userName); this.userName = new SimpleStringProperty((userName == null || userName.isBlank())? USER_NONE : userName);
try {
setConnection(NetworkHandler.openConnection(this.serverAddress.get(), this.serverPort.get()));
} catch (IOException e) {
messages.addMessage(new Message(Message.MessageType.ERROR,null,null,e.getMessage()));
System.out.println("ERROR: " + e.getMessage());
}
} }
public SimpleStringProperty getServerAddressProperty() { return serverAddress; } public SimpleStringProperty getServerAddressProperty() { return serverAddress; }