Package org.jboss.netty.buffer

Examples of org.jboss.netty.buffer.BigEndianHeapChannelBuffer.array()


        int size = message.getSerializedSize();
        ChannelBuffer buffer = new BigEndianHeapChannelBuffer(4 + size + 4);
        buffer.writeBytes("RPC0".getBytes());
        int writerIndex = buffer.writerIndex();
        CodedOutputStream output = CodedOutputStream.newInstance(
                buffer.array(), buffer.writerIndex(), buffer.writableBytes() - 4);
        message.writeTo(output);
        output.checkNoSpaceLeft();

        buffer.writerIndex(writerIndex + size);
        Adler32 checksum = new Adler32();
View Full Code Here


        message.writeTo(output);
        output.checkNoSpaceLeft();

        buffer.writerIndex(writerIndex + size);
        Adler32 checksum = new Adler32();
        checksum.update(buffer.array(), buffer.arrayOffset(), buffer.readableBytes());
        buffer.writeInt((int) checksum.getValue());
        return buffer;
    }
}
View Full Code Here

        buffer.writeBytes(name.getBytes());
        buffer.writeZero(1);
        buffer.writeBytes(message.toByteArray());

        Adler32 checksum = new Adler32();
        checksum.update(buffer.array(), buffer.arrayOffset(), buffer.readableBytes());
        buffer.writeInt((int) checksum.getValue());

        return buffer;
    }
}
View Full Code Here

        @SuppressWarnings("unchecked")
        @Override
        public <T> T convertTo(Class<T> type, Exchange exchange, Object value)
                throws TypeConversionException {
            BigEndianHeapChannelBuffer buffer = BigEndianHeapChannelBuffer.class.cast(value);
            return (T) new String(buffer.array());
        }
    }
}
View Full Code Here

    @Override
    public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
        BigEndianHeapChannelBuffer message = (BigEndianHeapChannelBuffer) e.getMessage();
        // System.out.println("messageReceived " + ctx.getChannel() + message.readableBytes());
        received += message.readableBytes();
        digest.update(message.array(), message.readerIndex(), message.readableBytes());
        if (received > maxLength) {
            System.out.println("messageReceived tid=" + Thread.currentThread().getId()
                    + " " + id + " got " + received);
            ctx.getChannel().close();
        }
View Full Code Here

        int size = message.getSerializedSize();
        ChannelBuffer buffer = new BigEndianHeapChannelBuffer(4 + size + 4);
        buffer.writeBytes("RPC0".getBytes());
        int writerIndex = buffer.writerIndex();
        CodedOutputStream output = CodedOutputStream.newInstance(
                buffer.array(), buffer.writerIndex(), buffer.writableBytes() - 4);
        message.writeTo(output);
        output.checkNoSpaceLeft();

        buffer.writerIndex(writerIndex + size);
        Adler32 checksum = new Adler32();
View Full Code Here

        message.writeTo(output);
        output.checkNoSpaceLeft();

        buffer.writerIndex(writerIndex + size);
        Adler32 checksum = new Adler32();
        checksum.update(buffer.array(), buffer.arrayOffset(), buffer.readableBytes());
        buffer.writeInt((int) checksum.getValue());
        return buffer;
    }
}
View Full Code Here

        buffer.writeBytes(name.getBytes());
        buffer.writeZero(1);
        buffer.writeBytes(message.toByteArray());

        Adler32 checksum = new Adler32();
        checksum.update(buffer.array(), buffer.arrayOffset(), buffer.readableBytes());
        buffer.writeInt((int) checksum.getValue());

        return buffer;
    }
}
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.