|
@@ -23,6 +23,7 @@ import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.context.event.EventListener;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
/**
|
|
@@ -31,9 +32,9 @@ import org.springframework.stereotype.Service;
|
|
|
* @author L.cm
|
|
|
*/
|
|
|
@Service
|
|
|
+@Component
|
|
|
public class MqttClientConnectListener {
|
|
|
private static final Logger logger = LoggerFactory.getLogger(MqttClientConnectListener.class);
|
|
|
-
|
|
|
@Autowired
|
|
|
private MqttClientCreator mqttClientCreator;
|
|
|
|
|
@@ -47,8 +48,8 @@ public class MqttClientConnectListener {
|
|
|
logger.info("MqttDisconnectEvent:{}", event);
|
|
|
// 在断线时更新 clientId、username、password
|
|
|
mqttClientCreator.clientId("newClient" + System.currentTimeMillis())
|
|
|
- .username("liruoxiu_test")
|
|
|
- .password("123456");
|
|
|
+ .username(mqttClientCreator.getUsername())
|
|
|
+ .password(mqttClientCreator.getPassword());
|
|
|
}
|
|
|
|
|
|
}
|