| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | | * @author T14 |
| | | */ |
| | | @Service |
| | | public class MqttPushCallback implements MqttCallback { |
| | | @Autowired |
| | | private DeviceSubcribeService deviceSubcribeService; |
| | | //接收消息回调 |
| | | @Override |
| | | public void connectionLost(Throwable cause) { |
| | | |
| | | // 连接丢失后,一般在这里面进行重连 |
| | | System.out.println("连接断开,可以做重连"); |
| | | } |
| | | |
| | | @Override |
| | | public void deliveryComplete(IMqttDeliveryToken token) { |
| | | System.out.println("deliveryComplete---------" + token.isComplete()); |
| | | } |
| | | |
| | | @Override |
| | | public void messageArrived(String topic, MqttMessage message) throws Exception { |
| | | // subscribe后得到的消息会执行到这里面 |
| | | System.out.println("接收消息主题 : " + topic); |