@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
protected void encode(ChannelHandlerContext ctx, Packet packet, List out) throws Exception {
ByteBuf buf = ctx.alloc().buffer().order(ByteOrder.LITTLE_ENDIAN);
int packetId = PacketRegistry.SERVER2CLIENT.getPacketId(packet.getClass());
if (packetId == -1) {
throw new IllegalArgumentException("Provided packet is not registered as a clientbound packet!");
}
buf.writeByte(packetId);
packet.writeData(buf);
new BinaryWebSocketFrame(buf);
out.add(new BinaryWebSocketFrame(buf));
Log.logDebug("Sent packet ID " + packetId + " (" + packet.getClass().getSimpleName() + ") to " + ctx.channel().remoteAddress());
}
PacketEncoder.java 文件源码
java
阅读 30
收藏 0
点赞 0
评论 0
项目:FPAgar
作者:
评论列表
文章目录