@Override
    public void writeObject(ByteBuffer buffer, Object object) throws IOException {
        if (!(object instanceof ZIPCompressedMessage)) return;

        ZIPCompressedMessage zipMessage = (ZIPCompressedMessage)object;
        Message message = zipMessage.getMessage();
        ByteBuffer tempBuffer = ByteBuffer.allocate(512000);
        Serializer.writeClassAndObject(tempBuffer, message);

        ByteArrayOutputStream byteArrayOutput = new ByteArrayOutputStream();
        ZipOutputStream zipOutput = new ZipOutputStream(byteArrayOutput);
        zipOutput.setLevel(zipMessage.getLevel());

        ZipEntry zipEntry = new ZipEntry("zip");

        zipOutput.putNextEntry(zipEntry);
        tempBuffer.flip();
        zipOutput.write(tempBuffer.array(), 0, tempBuffer.limit());
        zipOutput.flush();
        zipOutput.closeEntry();
        zipOutput.close();

        buffer.put(byteArrayOutput.toByteArray());
    }
Serializes ZIP messages.

@author Lars Wesselius
jme3-networking/src/main/java/com/jme3/network/serializing/serializers/ZIPSerializer.java