@Override
    public OFInstructionIdBsnAutoNegotiation readFrom(ByteBuf bb) throws OFParseError {
      int start = bb.readerIndex();
      // fixed value property type == 65535
      short type = bb.readShort();
      if (type != (short) 0xffff)
        throw new OFParseError(
            "Wrong type: Expected=OFInstructionType.EXPERIMENTER(65535), got=" + type);
      int length = U16.f(bb.readShort());
      if (length != 12) throw new OFParseError("Wrong length: Expected=12(12), got=" + length);
      if (bb.readableBytes() + (bb.readerIndex() - start) < length) {
        // Buffer does not have all data yet
        bb.readerIndex(start);
        return null;
      }
      if (logger.isTraceEnabled()) logger.trace("readFrom - length={}", length);
      // fixed value property experimenter == 0x5c16c7L
      int experimenter = bb.readInt();
      if (experimenter != 0x5c16c7)
        throw new OFParseError(
            "Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got=" + experimenter);
      // fixed value property subtype == 0xbL
      int subtype = bb.readInt();
      if (subtype != 0xb)
        throw new OFParseError("Wrong subtype: Expected=0xbL(0xbL), got=" + subtype);

      if (logger.isTraceEnabled())
        logger.trace("readFrom - returning shared instance={}", INSTANCE);
      return INSTANCE;
    }
Пример #2
0
 @Override
 public void decodeInto(ChannelHandlerContext ctx, ByteBuf buffer) {
   x = buffer.readInt();
   y = buffer.readInt();
   z = buffer.readInt();
   buf = buffer;
 }
Пример #3
0
 @Override
 public void readDataFromNetwork(ByteBuf in, byte id, NBTTagCompound nbt) {
   if (id == 0) nbt.setInteger("laserX", in.readInt());
   else if (id == 1) nbt.setInteger("laserZ", in.readInt());
   else if (id == 2) nbt.setBoolean("isRunning", in.readBoolean());
   else if (id == 3) nbt.setInteger("mode", in.readInt());
 }
    @Override
    public OFPortDesc readFrom(ByteBuf bb) throws OFParseError {
      OFPort portNo = OFPort.read4Bytes(bb);
      // pad: 4 bytes
      bb.skipBytes(4);
      MacAddress hwAddr = MacAddress.read6Bytes(bb);
      // pad: 2 bytes
      bb.skipBytes(2);
      String name = ChannelUtils.readFixedLengthString(bb, 16);
      Set<OFPortConfig> config = OFPortConfigSerializerVer12.readFrom(bb);
      Set<OFPortState> state = OFPortStateSerializerVer12.readFrom(bb);
      Set<OFPortFeatures> curr = OFPortFeaturesSerializerVer12.readFrom(bb);
      Set<OFPortFeatures> advertised = OFPortFeaturesSerializerVer12.readFrom(bb);
      Set<OFPortFeatures> supported = OFPortFeaturesSerializerVer12.readFrom(bb);
      Set<OFPortFeatures> peer = OFPortFeaturesSerializerVer12.readFrom(bb);
      long currSpeed = U32.f(bb.readInt());
      long maxSpeed = U32.f(bb.readInt());

      OFPortDescVer12 portDescVer12 =
          new OFPortDescVer12(
              portNo,
              hwAddr,
              name,
              config,
              state,
              curr,
              advertised,
              supported,
              peer,
              currSpeed,
              maxSpeed);
      if (logger.isTraceEnabled()) logger.trace("readFrom - read={}", portDescVer12);
      return portDescVer12;
    }
 @Override
 public void fromBytes(ByteBuf buf) {
   entityID = buf.readInt();
   componentID = buf.readInt();
   if (buf.readBoolean()) ident = TrackIdentifier.deserialize(buf);
   progress = buf.readFloat();
 }
Пример #6
0
 @Override
 public void fromBytes(ByteBuf buf) {
   x = buf.readInt();
   y = buf.readInt();
   z = buf.readInt();
   storedEnergy = buf.readFloat();
 }
  private boolean handleDataFrame(ByteBuf in, List<Object> out) {
    if (!in.isReadable(FRAME_DATA_HEADER_LENGTH)) {
      return false;
    }

    int sequenceNumber = in.readInt();
    int entriesCount = in.readInt();

    Map<String, String> dataMessage = new LinkedHashMap<>();

    while (entriesCount-- > 0) {
      String key = readLengthPrefixedString(in);
      if (key == null) {
        return false;
      }

      String value = readLengthPrefixedString(in);
      if (value == null) {
        return false;
      }

      dataMessage.put(key, value);
    }

    out.add(new LumberjackMessage(sequenceNumber, dataMessage));
    return true;
  }
 @Override
 public void decodeFrom(ChannelHandlerContext ctx, ByteBuf buffer) throws IOException {
   data = new byte[buffer.readInt()];
   signature = new byte[buffer.readInt()];
   buffer.readBytes(data);
   buffer.readBytes(signature);
 }
 @Override
 public void fromBytes(ByteBuf buffer) {
   int ownerLength = buffer.readInt();
   this.owner = new String(buffer.readBytes(ownerLength).array());
   int notifierLength = buffer.readInt();
   this.notifier = new String(buffer.readBytes(notifierLength).array());
 }
Пример #10
0
  public NettyMessage decode(ByteBuf in) throws Exception {
    NettyMessage message = new NettyMessage();
    Header header = new Header();
    header.setCrcCode(in.readInt());
    header.setLength(in.readInt());
    header.setSessionID(in.readLong());
    header.setType(in.readByte());
    header.setPriority(in.readByte());

    int size = in.readInt();
    if (size > 0) {
      Map<String, Object> attch = new HashMap<String, Object>(size);
      int keySize = 0;
      byte[] keyArray = null;
      String key = null;
      for (int i = 0; i < size; i++) {
        keySize = in.readInt();
        keyArray = new byte[keySize];
        in.readBytes(keyArray);
        key = new String(keyArray, "UTF-8");
        attch.put(key, marshallingDecoder.decode(in));
      }
      keyArray = null;
      key = null;
      header.setAttachment(attch);
    }
    if (in.readableBytes() > 4) {
      message.setBody(marshallingDecoder.decode(in));
    }
    message.setHeader(header);
    return message;
  }
 @Override
 public void read(ByteBuf bb) {
   uuidString = readString(bb);
   time = bb.readInt();
   action = bb.readInt();
   teleportString = readString(bb);
 }
Пример #12
0
  @Override
  protected Object decode(ChannelHandlerContext ctx, ByteBuf in) throws Exception {
    // TODO Auto-generated method stub
    ByteBuf frame = (ByteBuf) super.decode(ctx, in);
    if (frame == null) {
      return null;
    }

    Message message = new Message();
    Header header = new Header();

    header.setSrcCode(in.readInt());
    header.setLength(in.readInt());
    header.setSessionId(in.readLong());
    header.setType(in.readByte());
    header.setPriority(in.readByte());
    int size = in.readInt();
    if (size > 0) {
      Map<String, Object> attch = new HashMap<String, Object>(size);
      int keySize = 0;
      byte[] keyArray = null;
      String key = null;
      for (int i = 0; i < size; i++) {
        keySize = in.readInt();
        keyArray = new byte[keySize];
        in.readBytes(keyArray);
        key = new String(keyArray, "UTF-8");
        attch.put(key, nettyMarshallingDecoder.decode(ctx, in));
      }
      keyArray = null;
      key = null;
      header.setAttachment(attch);
    }
    return message;
  }
 @Override
 public void fromBytes(ByteBuf buf) {
   int elementNameLength = buf.readInt();
   this.elementName = new String(buf.readBytes(elementNameLength).array());
   int elementTextLength = buf.readInt();
   this.elementText = new String(buf.readBytes(elementTextLength).array());
 }
Пример #14
0
  @Override
  public void fromBytes(ByteBuf buf) {
    this.color = buf.readInt();
    for (int i = 0; i < 16; i++) {
      String current = "";
      for (int i2 = 1; i2 < 5; i++) {
        int currentScreen = buf.readInt();
        current = current + Integer.toString(currentScreen).substring(1);
      }
      this.screen[i] = current;
    }
    /*String screenNumS;
    String screenData;
    this.screenNum = buf.readInt();
    //Packet = 1<color><screenData>
    //Remove   ^
    screenNumS = Integer.toString(this.screenNum).substring(1);
    this.color = Integer.getInteger(screenNumS.substring(2,2));
    screenData = screenNumS.substring(2);
    //Get the screen variable
    for (int i = 0;i <16;i++){
    	int iU = i == 0 ? 1 : i * 16;
    	this.screen[i] = screenData.substring(iU, iU+16);
    }*/

  }
 @Override
 public void fromBytes(ByteBuf buf) {
   this.x = buf.readInt();
   this.y = buf.readInt();
   this.z = buf.readInt();
   this.data = buf.readInt();
 }
Пример #16
0
  @Override
  public void fromBytes(ByteBuf buf) {
    posX = buf.readInt();
    posY = buf.readInt();
    posZ = buf.readInt();
    int size = buf.readInt();

    data = new ArrayList(size);
    for (int i = 0; i < size; i++) {
      byte tag = buf.readByte();
      if (tag == 0x00) {
        data.add(buf.readChar());
      } else if (tag == 0x01) {
        data.add(readString(buf));
      } else if (tag == 0x02) {
        data.add(buf.readFloat());
      } else if (tag == 0x03) {
        data.add(buf.readDouble());
      } else if (tag == 0x04) {
        data.add(buf.readByte());
      } else if (tag == 0x05) {
        data.add(buf.readLong());
      } else {
        data.add(buf.readInt());
      }
    }
  }
 @Override
 public void readFrom(ByteBuf buffer, Side side) {
   host = ByteBufUtils.readUTF8String(buffer);
   x = buffer.readInt();
   y = buffer.readInt();
   z = buffer.readInt();
   ident = ByteBufUtils.readUTF8String(buffer);
 }
  @Override
  public void fromBytes(ByteBuf buf) {
    this.x = buf.readInt();
    this.y = buf.readInt();
    this.z = buf.readInt();

    this.player = ByteBufUtils.readUTF8String(buf);
  }
Пример #19
0
 private static Block[] readFluidArrayFromBuf(ByteBuf buf) {
   List<Block> blocks = new ArrayList<Block>();
   int size = buf.readInt();
   for (int i = 0; i < size; i++) {
     blocks.add((Block) Block.blockRegistry.getObjectById(buf.readInt()));
   }
   return blocks.toArray(new Block[blocks.size()]);
 }
Пример #20
0
 @Override
 public void decodeInto(ChannelHandlerContext ctx, ByteBuf buffer) {
   playerNames = new String[buffer.readInt()];
   races = new int[playerNames.length];
   for (int i = 0; i < playerNames.length; i++) {
     playerNames[i] = ByteBufUtils.readUTF8String(buffer);
     races[i] = buffer.readInt();
   }
 }
 @Override
 public void decodeInto(ChannelHandlerContext ctx, ByteBuf buffer) {
   this.dim = buffer.readInt();
   this.x = buffer.readInt();
   this.y = buffer.readInt();
   this.z = buffer.readInt();
   this.rotation = buffer.readDouble();
   this.scale = buffer.readDouble();
 }
 @Override
 public void fromBytes(ByteBuf buf) {
   x = buf.readInt();
   y = buf.readInt();
   z = buf.readInt();
   _freq = buf.readInt();
   _isPublic = buf.readBoolean();
   _state = buf.readByte();
 }
Пример #23
0
  public BlockChangeMessage decode(ByteBuf buffer) throws IOException {
    int x = buffer.readInt();
    int y = buffer.readByte();
    int z = buffer.readInt();
    int type = ByteBufUtils.readVarInt(buffer);
    int metadata = buffer.readByte();

    return new BlockChangeMessage(x, y, z, type, metadata);
  }
Пример #24
0
 private static BlockMeta[] readBlockArrayFromBuf(ByteBuf buf) {
   int size = buf.readInt();
   List<BlockMeta> blocksMeta = new ArrayList<BlockMeta>();
   for (int i = 0; i < size; i++) {
     Block b = (Block) Block.blockRegistry.getObjectById(buf.readInt());
     int m = buf.readInt();
     blocksMeta.add(new BlockMeta(b, m));
   }
   return blocksMeta.toArray(new BlockMeta[blocksMeta.size()]);
 }
Пример #25
0
 public static View deserialiseView(ByteBuf buf) {
   int id = buf.readInt();
   int memsize = buf.readInt();
   ImmutableSortedSet.Builder<Address> addrs = ImmutableSortedSet.naturalOrder();
   for (int i = 0; i < memsize; i++) {
     Address addr = (Address) AddressSerializer.INSTANCE.fromBinary(buf, Optional.absent());
     addrs.add(addr);
   }
   return new View(addrs.build(), id);
 }
  @Override
  public void handlePacketData(ByteBuf dataStream) {
    if (!worldObj.isRemote) {
      int type = dataStream.readInt();

      switch (type) {
        case 0:
          if (getReactor() != null) getReactor().setInjectionRate(dataStream.readInt());
          break;
      }

      return;
    }

    super.handlePacketData(dataStream);

    if (worldObj.isRemote) {
      boolean formed = dataStream.readBoolean();

      if (formed) {
        if (getReactor() == null || !((FusionReactor) getReactor()).formed) {
          Mekanism.proxy.doGenericSparkle(
              this,
              new INodeChecker() {
                @Override
                public boolean isNode(TileEntity tile) {
                  return tile instanceof TileEntityReactorBlock;
                }
              });
        }

        if (getReactor() == null) {
          setReactor(new FusionReactor(this));
          MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord);
        }

        ((FusionReactor) getReactor()).formed = true;
        getReactor().setPlasmaTemp(dataStream.readDouble());
        getReactor().setCaseTemp(dataStream.readDouble());
        getReactor().setInjectionRate(dataStream.readInt());
        getReactor().setBurning(dataStream.readBoolean());
        fuelTank.setGas(new GasStack(GasRegistry.getGas("fusionFuelDT"), dataStream.readInt()));
        deuteriumTank.setGas(new GasStack(GasRegistry.getGas("deuterium"), dataStream.readInt()));
        tritiumTank.setGas(new GasStack(GasRegistry.getGas("tritium"), dataStream.readInt()));
        waterTank.setCapacity(dataStream.readInt());
        waterTank.setFluid(new FluidStack(FluidRegistry.getFluid("water"), dataStream.readInt()));
        steamTank.setCapacity(dataStream.readInt());
        steamTank.setFluid(new FluidStack(FluidRegistry.getFluid("steam"), dataStream.readInt()));
      } else if (getReactor() != null) {
        setReactor(null);
        MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord);
      }
    }
  }
  @Override
  public void fromBytes(ByteBuf buf) {
    world = DimensionManager.getWorld(buf.readInt());

    try {
      packet = EnumConnectionState.PLAY.getPacket(EnumPacketDirection.SERVERBOUND, buf.readInt());
      packet.readPacketData(new PacketBuffer(buf));
    } catch (InstantiationException | IllegalAccessException | IOException e) {
      throw new DecoderException(e);
    }
  }
Пример #28
0
  public void readFromStream(ByteBuf stream) {
    initialized = stream.readBoolean();

    xMin = stream.readInt();
    yMin = stream.readInt();
    zMin = stream.readInt();

    xMax = stream.readInt();
    yMax = stream.readInt();
    zMax = stream.readInt();
  }
  @Override
  protected void channelRead0(ChannelHandlerContext ctx, FMLProxyPacket msg) throws Exception {

    ByteBuf buf = msg.payload();
    int x = buf.readInt();
    int y = buf.readInt();
    int z = buf.readInt();
    TileEntity te = ShadowCraftEvolved.proxy.getClientPlayer().worldObj.getTileEntity(x, y, z);
    if (te instanceof TileEntitySCE) {
      ((TileEntitySCE) te).readFromPacket(buf);
    }
  }
  @Override
  public void handlePacketData(ByteBuf data) {
    if (FMLCommonHandler.instance().getEffectiveSide().isClient()) {
      int gasID = data.readInt();

      if (gasID < 0) {
        collectedGas.setGas(null);
      } else {
        collectedGas.setGas(new GasStack(gasID, data.readInt()));
      }
    }
  }