Package be.demmel.jgws.packets

Examples of be.demmel.jgws.packets.PacketArray


        LOGGER.warn("int[] deserialization unsupported, will throw an UnsupportedOperationException when used");
        readActions.add((packet, dataToDeserialize) -> {
          throw new UnsupportedOperationException("int[] deserialization unsupported (aka TODO)");
        });
      } else if (type == short[].class) {
        PacketArray packetArray = field.getAnnotation(PacketArray.class);
        final boolean constant = packetArray.constant();
        final int arraySize = packetArray.size();

        readActions.add((packet, dataToDeserialize) -> {
          int lengthOfArray = 0;
          if (!constant) {
            // read the length of the variable byte array, which is a unsigned short
View Full Code Here


            LOGGER.error("Unexpected error: ", e);
            throw new RuntimeException(e);
          }
        });
      } else if (type == long[].class) {
        PacketArray packetArray = field.getAnnotation(PacketArray.class);
        final boolean constant = packetArray.constant();
        final int constantLength = packetArray.size();
        writeActions.add((packet, buffer) -> {
          try {
            long[] data = (long[]) field.get(packet);
            if (!constant) {
              buffer.writeShort(data.length);
            } else {
              // Verify the length of the constant packet
              if (data.length != constantLength) {
                throw new RuntimeException("The length of the constant array doesn't match the annotation");
              }
            }

            RawConverter.writeUnsignedIntArray(data, buffer);
          } catch (IllegalArgumentException | IllegalAccessException e) {
            // should never happen
            LOGGER.error("Unexpected error: ", e);
            throw new RuntimeException(e);
          }
        });
      } else if (type == int[].class) {
        PacketArray packetArray = field.getAnnotation(PacketArray.class);
        final boolean constant = packetArray.constant();
        writeActions.add((packet, buffer) -> {
          try {
            if (!constant) {
              buffer.writeShort(((int[]) field.get(packet)).length);
            }

            RawConverter.writeUnsignedShortArray((int[]) field.get(packet), buffer);
          } catch (IllegalArgumentException | IllegalAccessException e) {
            // should never happen
            LOGGER.error("Unexpected error: ", e);
            throw new RuntimeException(e);
          }
        });
      } else if (type == short[].class) {
        PacketArray packetArray = field.getAnnotation(PacketArray.class);
        final boolean constant = packetArray.constant();
        writeActions.add((packet, buffer) -> {
          try {
            if (!constant) {
              buffer.writeShort(((short[]) field.get(packet)).length);
            }
View Full Code Here

TOP

Related Classes of be.demmel.jgws.packets.PacketArray

Copyright © 2018 www.massapicom. 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.