RpcCallCodec.java 文件源码

java
阅读 15 收藏 0 点赞 0 评论 0

项目:OpenModsLib 作者:
@Override
protected void encode(ChannelHandlerContext ctx, RpcCall call, List<Object> out) throws Exception {
    final PacketBuffer output = new PacketBuffer(Unpooled.buffer());

    {
        final IRpcTarget targetWrapper = call.target;
        int targetId = CommonRegistryCallbacks.mapObjectToId(targetRegistry, targetWrapper.getClass());
        output.writeVarInt(targetId);
        targetWrapper.writeToStream(output);
    }

    {
        final BiMap<MethodEntry, Integer> eventIdMap = CommonRegistryCallbacks.getEntryIdMap(methodRegistry);
        int methodId = eventIdMap.get(call.method);
        output.writeVarInt(methodId);
        MethodParamsCodec paramsCodec = call.method.paramsCodec;
        paramsCodec.writeArgs(output, call.args);
    }

    FMLProxyPacket packet = new FMLProxyPacket(output, RpcCallDispatcher.CHANNEL_NAME);
    out.add(packet);
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号