We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
有个疑问:encode会写入UdpAttachment,但是接收方decode数据包时又不关心发送方写入的UdpAttachment,所以encode那里是不是去掉UdpAttachment?
zfoo/net/src/main/java/com/zfoo/net/handler/codec/udp/UdpCodecHandler.java
Line 69 in 5b49303
public class UdpCodecHandler extends MessageToMessageCodec<DatagramPacket, EncodedPacketInfo> { @Override protected void decode(ChannelHandlerContext channelHandlerContext, DatagramPacket datagramPacket, List<Object> list) { ... var packetInfo = NetContext.getPacketService().read(sliceByteBuf); var sender = datagramPacket.sender(); packetInfo.setAttachment(UdpAttachment.valueOf(sender.getHostString(), sender.getPort())); list.add(packetInfo); } @Override protected void encode(ChannelHandlerContext channelHandlerContext, EncodedPacketInfo out, List<Object> list) { var byteBuf = channelHandlerContext.alloc().ioBuffer(); var udpAttachment = (UdpAttachment) out.getAttachment(); NetContext.getPacketService().write(byteBuf, out.getPacket(), out.getAttachment()); list.add(new DatagramPacket(byteBuf, new InetSocketAddress(udpAttachment.getHost(), udpAttachment.getPort()))); } }
The text was updated successfully, but these errors were encountered:
是可以的,欢迎提pr优化
Sorry, something went wrong.
No branches or pull requests
有个疑问:encode会写入UdpAttachment,但是接收方decode数据包时又不关心发送方写入的UdpAttachment,所以encode那里是不是去掉UdpAttachment?
zfoo/net/src/main/java/com/zfoo/net/handler/codec/udp/UdpCodecHandler.java
Line 69 in 5b49303
The text was updated successfully, but these errors were encountered: