fixed Issue #28 by checking if username contains space before starting connection
This commit is contained in:
parent
b47d98b960
commit
b6fd5b569d
|
@ -106,18 +106,22 @@ public class ChatWindowController {
|
||||||
|
|
||||||
private void startConnectionHandler() throws IOException {
|
private void startConnectionHandler() throws IOException {
|
||||||
String userName = userNameField.getText();
|
String userName = userNameField.getText();
|
||||||
String serverAddress = serverAddressField.getText();
|
if(!userName.contains(" ")) {
|
||||||
int serverPort = Integer.parseInt(serverPortField.getText());
|
String serverAddress = serverAddressField.getText();
|
||||||
connectionHandler = new ClientConnectionHandler(
|
int serverPort = Integer.parseInt(serverPortField.getText());
|
||||||
NetworkHandler.openConnection(serverAddress, serverPort), userName,
|
connectionHandler = new ClientConnectionHandler(
|
||||||
messages);
|
NetworkHandler.openConnection(serverAddress, serverPort), userName,
|
||||||
new Thread(connectionHandler).start();
|
messages);
|
||||||
|
new Thread(connectionHandler).start();
|
||||||
|
|
||||||
//register Listener
|
//register Listener
|
||||||
startListener();
|
startListener();
|
||||||
|
|
||||||
// register window close handler
|
// register window close handler
|
||||||
rootPane.getScene().getWindow().addEventHandler(WindowEvent.WINDOW_CLOSE_REQUEST, windowCloseHandler);
|
rootPane.getScene().getWindow().addEventHandler(WindowEvent.WINDOW_CLOSE_REQUEST, windowCloseHandler);
|
||||||
|
} else {
|
||||||
|
addError("It is not allowed to have spaces in username!");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void terminateConnectionHandler() {
|
private void terminateConnectionHandler() {
|
||||||
|
|
Loading…
Reference in New Issue