parent
8d86d19659
commit
6974d06d77
|
@ -209,6 +209,10 @@ public class ChangString {
|
|||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static Map.Entry<String, Object> parseJsonMap(Map.Entry<String, Object> entry,String key,String value,int keyindex){
|
||||
//如果是字符串型的null直接把对象设置为对象null
|
||||
if("NULL".equals(value)){
|
||||
value = null;
|
||||
}
|
||||
//如果是单个map继续遍历
|
||||
if(entry.getValue() instanceof Map){
|
||||
LinkedHashMap<String, Object> jsonMap = JSON.parseObject(entry.getValue().toString(), new TypeReference<LinkedHashMap<String, Object>>(){});
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package luckyclient.netty;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.URLDecoder;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
@ -65,8 +66,9 @@ public class ClientHandler extends ChannelHandlerAdapter {
|
|||
|
||||
@Override
|
||||
public void channelRead(ChannelHandlerContext ctx, Object msg) throws UnsupportedEncodingException, InterruptedException {
|
||||
//统一转编码
|
||||
String jsonStr = URLDecoder.decode(msg.toString(), "GBK");
|
||||
//服务端消息处理,如果接收到测试任务方法,则直接产生一个http请求并发送请求到本地
|
||||
String jsonStr = msg.toString();
|
||||
JSONObject json = new JSONObject();
|
||||
try {
|
||||
json = JSON.parseObject(jsonStr);
|
||||
|
@ -262,8 +264,8 @@ public class ClientHandler extends ChannelHandlerAdapter {
|
|||
super.userEventTriggered(ctx, evt);
|
||||
}
|
||||
|
||||
|
||||
public static void sendMessage(String json) throws InterruptedException {
|
||||
ctx.channel().writeAndFlush(Unpooled.copiedBuffer((json + "$_").getBytes()));
|
||||
}
|
||||
|
||||
}
|
|
@ -53,8 +53,8 @@ public class NettyClient {
|
|||
ByteBuf delimiter = Unpooled.copiedBuffer("$_".getBytes());
|
||||
ChannelPipeline p = ch.pipeline();
|
||||
p.addLast(new DelimiterBasedFrameDecoder(1024, delimiter));
|
||||
p.addLast("decoder", new StringDecoder(Charset.forName("GBK")));
|
||||
p.addLast("encoder", new StringEncoder(Charset.forName("UTF-8")));
|
||||
p.addLast("decoder", new StringDecoder(Charset.forName("UTF-8")));
|
||||
p.addLast("encoder", new StringEncoder(Charset.forName("GBK")));
|
||||
p.addLast(new IdleStateHandler(1,0,0,TimeUnit.SECONDS));
|
||||
p.addLast(clientHandler);
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ public class InvokeMethod {
|
|||
* @param functionname
|
||||
* @param getParameterValues
|
||||
* @param steptype
|
||||
* @param action
|
||||
* @param extend
|
||||
* @return
|
||||
*/
|
||||
public static String callCase(String packagename, String functionname, Object[] getParameterValues, int steptype, String extend) {
|
||||
|
|
|
@ -24,6 +24,10 @@ import luckyclient.utils.config.SysConfig;
|
|||
*/
|
||||
@SpringBootApplication
|
||||
public class RunService {
|
||||
/*
|
||||
* 注意:请不要在此处使用IDEA运行(Run)客户端,客户端的启动方式,请参照官网文档
|
||||
* 如果IDEA工具上运行时出现乱码,请设置VM options,添加-Dfile.encoding=GBK即可
|
||||
* */
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(RunService.class);
|
||||
private static final Boolean NETTY_MODEL= BooleanUtil.toBoolean(SysConfig.getConfiguration().getProperty("netty.model"));
|
||||
|
|
Loading…
Reference in New Issue