Added start of services
This commit is contained in:
parent
3f94756fa8
commit
14c925d480
1 changed files with 7 additions and 1 deletions
|
|
@ -57,11 +57,15 @@ public class HalMqttController implements HalAutoScannableController, MqttSubscr
|
||||||
try {
|
try {
|
||||||
InetAddress serverIp = InetUtil.getLocalInet4Address().get(0);
|
InetAddress serverIp = InetUtil.getLocalInet4Address().get(0);
|
||||||
|
|
||||||
|
logger.info("Starting up mDNS Server");
|
||||||
mDns = new MulticastDnsServer();
|
mDns = new MulticastDnsServer();
|
||||||
mDns.addEntry("_mqtt.tcp", serverIp);
|
mDns.addEntry("_mqtt.tcp", serverIp);
|
||||||
mDns.addEntry("hal.local", serverIp);
|
mDns.addEntry("hal.local", serverIp);
|
||||||
|
mDns.start();
|
||||||
|
|
||||||
|
logger.info("Starting up MQTT Server");
|
||||||
mqttBroker = new MqttBroker();
|
mqttBroker = new MqttBroker();
|
||||||
|
mqttBroker.start();
|
||||||
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
logger.log(Level.SEVERE, "Unable to initialize MQTT plugin.", e);
|
logger.log(Level.SEVERE, "Unable to initialize MQTT plugin.", e);
|
||||||
|
|
@ -72,17 +76,19 @@ public class HalMqttController implements HalAutoScannableController, MqttSubscr
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isAvailable() {
|
public boolean isAvailable() {
|
||||||
return mDns != null && mqttBroker != null;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void close(){
|
public void close(){
|
||||||
if (mDns != null) {
|
if (mDns != null) {
|
||||||
|
logger.info("Shutting down mDNS Server");
|
||||||
mDns.close();
|
mDns.close();
|
||||||
mDns = null;
|
mDns = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mqttBroker != null) {
|
if (mqttBroker != null) {
|
||||||
|
logger.info("Shutting down MQTT Server");
|
||||||
mqttBroker.close();
|
mqttBroker.close();
|
||||||
mqttBroker = null;
|
mqttBroker = null;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue