fixed server join logic
This commit is contained in:
@@ -68,9 +68,7 @@ public void run() {
|
||||
private void startServer() {
|
||||
try {
|
||||
LOGGER.log(Level.INFO, "Starting server..."); //NON-NLS
|
||||
InetAddress localhost;
|
||||
localhost = InetAddress.getLocalHost();
|
||||
String ip = localhost.getHostAddress();
|
||||
|
||||
myServer = Network.createServer(port);
|
||||
initializeSerializables();
|
||||
myServer.start();
|
||||
|
||||
@@ -126,7 +126,7 @@ private void tryHost() {
|
||||
private void tryJoin() {
|
||||
int port = 0;
|
||||
String ip = joinDialog.getIpt();
|
||||
String portText = hostDialog.getPort();
|
||||
String portText = joinDialog.getPort();
|
||||
|
||||
try {
|
||||
// Validate the port
|
||||
@@ -134,9 +134,10 @@ private void tryJoin() {
|
||||
if (port < 1 || port > 65535) {
|
||||
throw new IllegalArgumentException("Invalid port");
|
||||
}
|
||||
|
||||
joinDialog.setPortNumber(port);
|
||||
// Validate the IP address
|
||||
if (isValidIpAddress(ip)) {
|
||||
joinDialog.setHostname(ip);
|
||||
app.getModelSynchronize().setName(startDialog.getName());
|
||||
app.getModelSynchronize().setJoin(ip, port);
|
||||
joinDialog.connectToServer();
|
||||
@@ -146,7 +147,7 @@ private void tryJoin() {
|
||||
// Invalid input, fall through to reset
|
||||
}
|
||||
|
||||
hostDialog.resetPort();
|
||||
joinDialog.resetPort();
|
||||
joinDialog.resetIp();
|
||||
app.getAcousticHandler().playSound(MdgaSound.WRONG_INPUT);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user