修复路由器扫描问题
This commit is contained in:
parent
59477d518a
commit
e0751972a3
@ -31,22 +31,24 @@ public class MiRouter extends Model {
|
||||
@Override
|
||||
public void onMessage(Long qq, MessageEvent event, boolean isGroup) {
|
||||
super.onMessage(qq, event, isGroup);
|
||||
if(msg.equals(QQFromCommands.ROUTER_ADD)){
|
||||
String url="http://192.168.31.88:8002/router/device/add.do?qq="+qq;
|
||||
QQBotManager.getInstance().sendMessage(qq,"点击该链接完成设备添加:\n"+url);
|
||||
}else if(msg.equals(QQFromCommands.ROUTER_DEL)){
|
||||
String url="http://192.168.31.88:8002/router/device/del.do?qq="+qq;
|
||||
QQBotManager.getInstance().sendMessage(qq,"点击该删除设备:\n"+url);
|
||||
if (msg.equals(QQFromCommands.ROUTER_ADD)) {
|
||||
String url = "http://192.168.31.88:8002/router/device/add.do?qq=" + qq;
|
||||
QQBotManager.getInstance().sendMessage(qq, "点击该链接完成设备添加:\n" + url);
|
||||
} else if (msg.equals(QQFromCommands.ROUTER_DEL)) {
|
||||
String url = "http://192.168.31.88:8002/router/device/del.do?qq=" + qq;
|
||||
QQBotManager.getInstance().sendMessage(qq, "点击该删除设备:\n" + url);
|
||||
}
|
||||
}
|
||||
private static boolean isRunTime=false;
|
||||
|
||||
private static boolean isRunTime = false;
|
||||
|
||||
@Override
|
||||
public void onTime(String time) {
|
||||
super.onTime(time);
|
||||
if(isRunTime){
|
||||
if (isRunTime) {
|
||||
return;
|
||||
}
|
||||
isRunTime=true;
|
||||
isRunTime = true;
|
||||
String url = XiaoMiRouter.getDeviceListUrl();
|
||||
JSONObject json = JSONObject.parseObject(HttpTools.get(url));
|
||||
if (json.getInteger("code") == 0) {
|
||||
@ -68,6 +70,7 @@ public class MiRouter extends Model {
|
||||
builder.append(item.getString("oname"));
|
||||
builder.append(" 欢迎回家!").append("\n");
|
||||
builder.append("点击该链接开门:").append("\n");
|
||||
builder.append("http://192.168.31.88:802/openDoor.html");
|
||||
QQBotManager.getInstance().sendMessage(_device.getLong("qq"), builder.toString());
|
||||
_device.put("online", true);
|
||||
_device.put("name", item.getString("oname"));
|
||||
@ -82,7 +85,7 @@ public class MiRouter extends Model {
|
||||
devices = (JSONArray) devs.clone();
|
||||
for (Object device : devices) {
|
||||
JSONObject item = (JSONObject) device;
|
||||
if (!links.contains(item.getString("mac"))&&item.getLong("linkTime")!=0) {
|
||||
if (!links.contains(item.getString("mac")) && item.getLong("linkTime") != 0) {
|
||||
devs.remove(device);
|
||||
String builder = "你的设备:" +
|
||||
item.getString("name") +
|
||||
@ -90,13 +93,13 @@ public class MiRouter extends Model {
|
||||
"在线时长:" + getOnLineTime(item.getString("linkTime")) + "\n";
|
||||
QQBotManager.getInstance().sendMessage(item.getLong("qq"), builder);
|
||||
item.put("online", false);
|
||||
item.put("linkTime",0);
|
||||
item.put("linkTime", 0);
|
||||
devs.add(item);
|
||||
}
|
||||
}
|
||||
RedisTools.set(redis_key, devs.toJSONString());
|
||||
isRunTime=false;
|
||||
}
|
||||
isRunTime = false;
|
||||
}
|
||||
|
||||
private String getOnLineTime(String online) {
|
||||
|
Loading…
Reference in New Issue
Block a user