return testport in method
This commit is contained in:
parent
d4bcff6f8c
commit
702fb399c3
@ -1,5 +1,7 @@
|
|||||||
package tools;
|
package tools;
|
||||||
|
|
||||||
|
import javafx.util.Pair;
|
||||||
|
|
||||||
/** Test ports.
|
/** Test ports.
|
||||||
* @author Louis Royer
|
* @author Louis Royer
|
||||||
* @author Flavien Haas
|
* @author Flavien Haas
|
||||||
@ -8,18 +10,19 @@ package tools;
|
|||||||
*/
|
*/
|
||||||
public class TestPort {
|
public class TestPort {
|
||||||
|
|
||||||
public boolean testPortServer(int port) {
|
public boolean testPortServer(int port, String message) {
|
||||||
if((port > 7000) && (port < 7999)){
|
if((port > 7000) && (port < 7999)){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
message = message + "Wrong port (7000 -> 7999), using default port 7070";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean testPortTracker(int port) {
|
public Pair<Integer,String> testPortTracker(int port) {
|
||||||
if((port > 6000) && (port < 6999)){
|
if((port > 6000) && (port < 6999)){
|
||||||
return true;
|
return new Pair<>(0,"");
|
||||||
}
|
}
|
||||||
return false;
|
return new Pair<>(1, "Wrong port (6000 -> 6999), using default port 6969");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package tracker;
|
package tracker;
|
||||||
|
|
||||||
import java.util.Scanner;
|
import java.util.Scanner;
|
||||||
|
import javafx.util.Pair;
|
||||||
import tracker.TrackerManagementTCP;
|
import tracker.TrackerManagementTCP;
|
||||||
import tracker.TrackerManagementUDP;
|
import tracker.TrackerManagementUDP;
|
||||||
import tools.Directories;
|
import tools.Directories;
|
||||||
@ -42,7 +43,7 @@ public class Tracker {
|
|||||||
final String defaultPort = "6969";
|
final String defaultPort = "6969";
|
||||||
final String defaultHostname = "localhost";
|
final String defaultHostname = "localhost";
|
||||||
Scanner scanner = new Scanner(System.in);
|
Scanner scanner = new Scanner(System.in);
|
||||||
TestPort testPortTracker = new TestPort();
|
TestPort testPort = new TestPort();
|
||||||
String hostname;
|
String hostname;
|
||||||
String port;
|
String port;
|
||||||
Tracker t;
|
Tracker t;
|
||||||
@ -73,14 +74,15 @@ public class Tracker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
System.out.println("using hostname : " + hostname);
|
System.out.println("using hostname : " + hostname);
|
||||||
if(testPortTracker.testPortTracker(Integer.parseInt(port))){
|
Pair<Integer, String> PtestPortTracker = testPort.testPortTracker(Integer.parseInt(port));
|
||||||
|
if(PtestPortTracker.getKey() == 0){
|
||||||
System.out.println("using port : " + port);
|
System.out.println("using port : " + port);
|
||||||
t = new Tracker(port);
|
t = new Tracker(port);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
System.out.println("Wrong port (6000 -> 6999), using default port 6969");
|
System.out.println(PtestPortTracker.getValue());
|
||||||
t = new Tracker(defaultPort);
|
t = new Tracker(defaultPort);
|
||||||
t.logger.write("Wrong port (6000 -> 6999), using default port 6969", LogLevel.Warning);
|
t.logger.write(PtestPortTracker.getValue(), LogLevel.Warning);
|
||||||
}
|
}
|
||||||
|
|
||||||
TrackerManagementUDP tmudp = new TrackerManagementUDP(hostname, t.port, t.logger);
|
TrackerManagementUDP tmudp = new TrackerManagementUDP(hostname, t.port, t.logger);
|
||||||
|
Loading…
Reference in New Issue
Block a user