Skip to content

Commit

Permalink
修改测试代码
Browse files Browse the repository at this point in the history
  • Loading branch information
ch0ice committed Jul 22, 2019
1 parent 79e9dc3 commit 672fdf9
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package cn.com.onlinetool.jt809.client;

import cn.com.onlinetool.jt809.util.ByteArrayUtil;
import io.netty.bootstrap.Bootstrap;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelInitializer;
Expand Down Expand Up @@ -48,6 +49,7 @@ protected void initChannel(SocketChannel socketChannel) throws Exception {
public void operationComplete(Future future) throws Exception {
if(future.isSuccess()){
System.out.println("服务器连接已经完成,可以确保进行消息准确传输");
channelFuture.channel().write(ByteArrayUtil.hexStr2Bytes("5B000000480000005210010001E24001000100000000000001E2407465737438303900312E37312E3132392E32303100000000000000000000000000000000000000004E8ED9BA5D"));
}
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ public class JT809TcpClientHandler extends ChannelInboundHandlerAdapter {
public void channelActive(ChannelHandlerContext ctx) throws Exception {
System.out.println("channelActive..........");
ctx.writeAndFlush(ByteArrayUtil.hexStr2Bytes(
"5B0000007300005A01821200022551250100010000000000B8D3474330373232000000000000000000000000000212010000003D3335303130320000000000373035303400000000000000000000000000000000000000000000000000003F001B3C000000303634383336323338353038A76C5D"
+ "5B0000007300005A01821200022551250100010000000000B8D3474330373232000000000000000000000000000212010000003D3335303130320000000000373035303400000000000000000000000000000000000000000000000000003F001B3C000000303634383336323338353038A76C5D"
"5B000000480000005210010001E24001000100000000000001E2407465737438303900312E37312E3132392E32303100000000000000000000000000000000000000004E8ED9BA5D"
));
super.channelActive(ctx);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ public class Message2ByteEncoder extends MessageToByteEncoder {
@Override
protected void encode(ChannelHandlerContext ctx, Object msg, ByteBuf byteBuf) throws Exception {
byteBuf.writeBytes((byte[]) msg);
ctx.writeAndFlush(byteBuf);
}
}

0 comments on commit 672fdf9

Please sign in to comment.