Commit 1c150dec authored by 赵啸非's avatar 赵啸非

修改消息组件

parent 325cdc45
......@@ -34,8 +34,7 @@ public class NettyUDPServerHandler extends SimpleChannelInboundHandler<DatagramP
}
@Override
protected void channelRead0(ChannelHandlerContext ctx, DatagramPacket msg) throws Exception {
DatagramPacket packet = (DatagramPacket) msg;
protected void channelRead0(ChannelHandlerContext ctx, DatagramPacket packet) throws Exception {
ByteBuf byteBuf = packet.copy().content();
byte[] bytes = new byte[byteBuf.readableBytes()];
......@@ -52,10 +51,11 @@ public class NettyUDPServerHandler extends SimpleChannelInboundHandler<DatagramP
resp.setData(URL);
InetSocketAddress remoteAddress = new InetSocketAddress("255.255.255.255", 7789);
//InetSocketAddress remoteAddress = new InetSocketAddress("255.255.255.255", 7789);
InetSocketAddress remoteAddress = new InetSocketAddress( packet.sender().getHostName(), 7789);
DatagramPacket sendpacket =new DatagramPacket(Unpooled.copiedBuffer(JSON.toJSONString(resp), CharsetUtil.UTF_8),remoteAddress);
//ctx.writeAndFlush(new DatagramPacket(Unpooled.copiedBuffer(JSON.toJSONString(resp), CharsetUtil.UTF_8), msg.sender()));
//ctx.writeAndFlush(new DatagramPacket(Unpooled.copiedBuffer(JSON.toJSONString(resp), CharsetUtil.UTF_8), packet.sender()));
ctx.writeAndFlush(sendpacket);
}
......
......@@ -71,7 +71,7 @@ POST {{baseUrl}}/api/register
Content-Type: application/json
{
"deviceCode":"AB:DD:DF:FD:AD:FA:DA:SS"
"deviceCode":"a12345678"
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment