Compare commits

...

3 commits

Author SHA1 Message Date
Mark Nellemann 369e96226f Ensure closing the window exits.
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
2023-08-14 20:03:50 +02:00
Mark Nellemann 8d5c8e67e2 Merge remote-tracking branch 'origin/main' 2023-08-14 19:42:48 +02:00
Mark Nellemann acf034e763 Merge remote-tracking branch 'origin/main' 2023-08-10 14:37:00 +02:00
4 changed files with 15 additions and 52 deletions

View file

@ -1 +1 @@
version = 0.0.1
version = 0.0.2

View file

@ -16,16 +16,14 @@ import java.io.IOException;
public class App extends Application {
@Override
public void init() {
Platform.setImplicitExit(true);
}
@Override
public void start(Stage primaryStage) throws IOException {
// Make all stages close and the app exit when the primary stage is closed
primaryStage.setOnCloseRequest(e -> Platform.exit());
Platform.setImplicitExit(true);
primaryStage.setOnCloseRequest(e -> {
System.exit(0);
});
// Set icon on the application bar
var appIcon = new Image("/icon.png");
@ -51,11 +49,6 @@ public class App extends Application {
}
@Override
public void stop() {
}
public static void main(String[] args) {
launch(args);
}

View file

@ -38,17 +38,9 @@ public class MainPresenter {
@FXML
public void initialize() {
log.info("initialize()");
view.addEventFilter(WindowEvent.WINDOW_CLOSE_REQUEST, event -> {
log.info("Window closing");
discoveryService.destroy();
});
discoveryService = new DiscoveryService();
discoveryService.initialize();
discoveryService.setObservableList(devicesList);
listView.setItems(devicesList);
listView.setCellFactory(p -> new NetworkServiceCell());
discoveryService = new DiscoveryService(devicesList);
}

View file

@ -20,16 +20,10 @@ public class DiscoveryService {
private final static Logger log = LoggerFactory.getLogger(DiscoveryService.class);
private ObservableList<NetworkService> observableList;
private final ObservableList<NetworkService> observableList;
private JmDNS jmdns;
/*private final HashMap<String, Color> services = HashMap<>({
"http", "https", "upnp", "ssh", "sip", "rdp", "ntp", "rdp", "rtsp",
"ntp", "smb", "nfs", "llrp", "ftp", "ep", "daap", "ipp", "ipps",
"googlecast", "sonos", "airplay", "smartenergy", "skype", "bittorrent"
);*/
// From: http://www.dns-sd.org/serviceTypes.html +
// https://jonathanmumm.com/tech-it/mdns-bonjour-bible-common-service-strings-for-various-vendors/ + some guesses
private final Map<String, Color> services = new HashMap<>() {{
@ -68,36 +62,20 @@ public class DiscoveryService {
//put("rdlink", Color.KHAKI);
}};
public DiscoveryService(ObservableList<NetworkService> list) {
log.info("DiscoveryService()");
this.observableList = list;
public void initialize() {
log.info("initialize()");
try {
jmdns = JmDNS.create(InetAddress.getByName("0.0.0.0"), "mdnsExplorer");
services.forEach((item, color) -> {
String service = String.format("_%s._%s.local.", item, "tcp");
NetworkServiceListener networkServiceListener = new NetworkServiceListener(service, observableList, color);
jmdns.addServiceListener(service, networkServiceListener);
});
} catch (IOException e) {
log.error("initialize() - {}", e.getMessage());
}
}
public void destroy() {
if(jmdns != null) {
try {
jmdns.close();
} catch (IOException e) {
log.error("destroy() - {}", e.getMessage());
}
}
}
public void setObservableList(ObservableList<NetworkService> list) {
this.observableList = list;
services.forEach((item, color) -> {
String service = String.format("_%s._%s.local.", item, "tcp");
NetworkServiceListener networkServiceListener = new NetworkServiceListener(service, observableList, color);
jmdns.addServiceListener(service, networkServiceListener);
});
}
}