优化代码结构,加入憨批提示
parent
308db184f2
commit
472280779e
|
@ -26,18 +26,4 @@ public class Common {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public static EventLoopGroup workerGroup = new NioEventLoopGroup();
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
int i = 0;
|
|
||||||
List<String> strings = JSONObject.parseArray(local_one, String.class);
|
|
||||||
for (String string : strings) {
|
|
||||||
int length = string.split(",")[1].length();
|
|
||||||
if (length > i){
|
|
||||||
i = length;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
System.out.println(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,8 @@ package com.muyu.common;
|
||||||
|
|
||||||
import com.muyu.pojo.Vehicle;
|
import com.muyu.pojo.Vehicle;
|
||||||
import io.netty.channel.ChannelHandlerContext;
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
|
import io.netty.channel.EventLoopGroup;
|
||||||
|
import io.netty.channel.nio.NioEventLoopGroup;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* netty 核心配置
|
* netty 核心配置
|
||||||
|
@ -18,6 +20,11 @@ public class Config {
|
||||||
*/
|
*/
|
||||||
public static final String DATA_PACK_SEPARATOR = "#$&*";
|
public static final String DATA_PACK_SEPARATOR = "#$&*";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 工作组配置
|
||||||
|
*/
|
||||||
|
public static EventLoopGroup workerGroup = new NioEventLoopGroup();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通道处理上下文
|
* 通道处理上下文
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -45,7 +45,7 @@ public class NettyClientInit {
|
||||||
try {
|
try {
|
||||||
Bootstrap b = new Bootstrap();
|
Bootstrap b = new Bootstrap();
|
||||||
mClientHandler = new NettyClientHandler();
|
mClientHandler = new NettyClientHandler();
|
||||||
b.group(Common.workerGroup).channel(NioSocketChannel.class)
|
b.group(Config.workerGroup).channel(NioSocketChannel.class)
|
||||||
// KeepAlive
|
// KeepAlive
|
||||||
.option(ChannelOption.SO_KEEPALIVE, true)
|
.option(ChannelOption.SO_KEEPALIVE, true)
|
||||||
// Handler
|
// Handler
|
||||||
|
@ -89,9 +89,9 @@ public class NettyClientInit {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} finally {
|
} finally {
|
||||||
//优雅的关闭工作组
|
//优雅的关闭工作组
|
||||||
Common.workerGroup.shutdownGracefully();
|
Config.workerGroup.shutdownGracefully();
|
||||||
//解决意外关闭的情况,重新创建工作组,新的默认工作组
|
//解决意外关闭的情况,重新创建工作组,新的默认工作组
|
||||||
Common.workerGroup = new NioEventLoopGroup();
|
Config.workerGroup = new NioEventLoopGroup();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -649,6 +649,10 @@
|
||||||
$("#vehicleMsgLog").append(msg);
|
$("#vehicleMsgLog").append(msg);
|
||||||
}
|
}
|
||||||
function startNettySendMsg(){
|
function startNettySendMsg(){
|
||||||
|
if ($("#gear").val() == "P"){
|
||||||
|
$.modal.msgError("你个憨批,驻车挡跑个锤子!!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
nettyMsgTime = setInterval("sendNettySendMsg()", 1000);
|
nettyMsgTime = setInterval("sendNettySendMsg()", 1000);
|
||||||
$.modal.msgSuccess("车辆开始上报")
|
$.modal.msgSuccess("车辆开始上报")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue