Package io.netty.buffer

Examples of io.netty.buffer.ByteBuf.slice()


        } else {
            this.delimiters = new ByteBuf[delimiters.length];
            for (int i = 0; i < delimiters.length; i ++) {
                ByteBuf d = delimiters[i];
                validateDelimiter(d);
                this.delimiters[i] = d.slice(d.readerIndex(), d.readableBytes());
            }
            lineBasedDecoder = null;
        }
        this.maxFrameLength = maxFrameLength;
        this.stripDelimiter = stripDelimiter;
View Full Code Here


        if (d < len) {
            encode3to4(src, d + off, len - d, dest, e, dialect);
            e += 4;
        } // end if: some padding needed

        return dest.slice(0, e);
    }

    private static void encode3to4(
            ByteBuf src, int srcOffset, int numSigBytes,
            ByteBuf dest, int destOffset, Base64Dialect dialect) {
View Full Code Here

                        "bad Base64 input character at " + i + ": " +
                        src.getUnsignedByte(i) + " (decimal)");
            }
        }

        return dest.slice(0, outBuffPosn);
    }

    private static int decode4to3(
            byte[] src, int srcOffset,
            ByteBuf dest, int destOffset, Base64Dialect dialect) {
View Full Code Here

    if(cl == null)
      throw new NullPointerException("Packet not registered for discriminator : " + discriminator);
   
    //Create an empty packet and decode our packet data into it
    PacketBase packet = cl.newInstance();
    packet.decodeInto(ctx, encodedData.slice());
    //Check the side and handle our packet accordingly
    switch(FMLCommonHandler.instance().getEffectiveSide())
    {
    case CLIENT :
    {
View Full Code Here

    if (packetClass == null) {
      throw new NullPointerException("No packet registered for discriminator: " + discriminator);
    }
    PacketBase pkt = packetClass.newInstance();
    pkt.decodeInto(ctx, payload.slice());

    EntityPlayer player;
    switch (FMLCommonHandler.instance().getEffectiveSide()) {
    case CLIENT:
      player = this.getClientPlayer();
View Full Code Here

    ByteBuf payload = msg.payload();
    int packetID = payload.readShort();
    final ModernPacket packet = PacketHandler.packetlist.get(packetID).template();
    packet.setDebugId(payload.readInt());
    ctx.attr(INBOUNDPACKETTRACKER).get().set(msg);
    packet.readData(new LPDataInputStream(payload.slice()));
    out.add(new InboundModernPacketWrapper(packet, MainProxy.proxy.getEntityPlayerFromNetHandler(msg.handler())));
  }

  @Override
  public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception
View Full Code Here

      DefaultContext context = getContext(sock);
      // We need to do this since it's possible the server is being used from a worker context
      if (context.isOnCorrectWorker(ch.eventLoop())) {
        try {
          vertx.setContext(context);
          sock.handleDataReceived(new Buffer(in.slice()));
        } catch (Throwable t) {
          context.reportException(t);
        }
      } else {
        final ByteBuf buf = in.readBytes(in.readableBytes());
View Full Code Here

public class LogEventDecoder extends MessageToMessageDecoder<DatagramPacket> {
    @Override
    protected void decode(ChannelHandlerContext ctx, DatagramPacket datagramPacket, List<Object> out) throws Exception {
        ByteBuf data = datagramPacket.content();
        int i = data.indexOf(0, data.readableBytes(), LogEvent.SEPARATOR);
        String filename = data.slice(0, i).toString(CharsetUtil.UTF_8);
        String logMsg =  data.slice(i + 1, data.readableBytes()).toString(CharsetUtil.UTF_8);

        LogEvent event = new LogEvent(datagramPacket.recipient(), System.currentTimeMillis(),
                filename,logMsg);
        out.add(event);
View Full Code Here

    @Override
    protected void decode(ChannelHandlerContext ctx, DatagramPacket datagramPacket, List<Object> out) throws Exception {
        ByteBuf data = datagramPacket.content();
        int i = data.indexOf(0, data.readableBytes(), LogEvent.SEPARATOR);
        String filename = data.slice(0, i).toString(CharsetUtil.UTF_8);
        String logMsg =  data.slice(i + 1, data.readableBytes()).toString(CharsetUtil.UTF_8);

        LogEvent event = new LogEvent(datagramPacket.recipient(), System.currentTimeMillis(),
                filename,logMsg);
        out.add(event);
    }
View Full Code Here

            ByteBuf frame =  (ByteBuf) super.decode(ctx, buffer);
            if (frame == null) {
                return null;
            }
            int index = frame.indexOf(frame.readerIndex(), frame.writerIndex(), (byte) ' ');
            return new Cmd(frame.slice(frame.readerIndex(), index), frame.slice(index +1, frame.writerIndex()));
        }
    }

    public static final class CmdHandler extends SimpleChannelInboundHandler<Cmd> {
        @Override
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.