Package org.jboss.netty.buffer

Examples of org.jboss.netty.buffer.ChannelBuffer.readBytes()


        @Override
        public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
            ChannelBuffer buffer = (ChannelBuffer) e.getMessage();
            synchronized (this) {
                buffer.readBytes(out, buffer.readableBytes());
                out.flush();
            }
        }

        @Override
View Full Code Here


              isEarlyTerminated = content.readableBytes() < message.getPreviewAmount();
            }
          while(content.readableBytes() > 0) {
            IcapChunk chunk = null;
            if(content.readableBytes() > chunkSize) {
              chunk = new DefaultIcapChunk(content.readBytes(chunkSize));
            } else {
              chunk = new DefaultIcapChunk(content.readBytes(content.readableBytes()));
            }
            chunk.setPreviewChunk(isPreview);
            chunk.setEarlyTermination(isEarlyTerminated);
View Full Code Here

          while(content.readableBytes() > 0) {
            IcapChunk chunk = null;
            if(content.readableBytes() > chunkSize) {
              chunk = new DefaultIcapChunk(content.readBytes(chunkSize));
            } else {
              chunk = new DefaultIcapChunk(content.readBytes(content.readableBytes()));
            }
            chunk.setPreviewChunk(isPreview);
            chunk.setEarlyTermination(isEarlyTerminated);
            fireDownstreamEvent(ctx,chunk,msgEvent);
            if(chunk.isLast() | content.readableBytes() <= 0) {
View Full Code Here

        // Create new position
        Position position = new Position();
        ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol());
       
        // Get device by id
        String id = buf.readBytes(16).toString(Charset.defaultCharset()).trim();
        try {
            position.setDeviceId(getDataManager().getDeviceByImei(id).getId());
        } catch(Exception error) {
            Log.warning("Unknown device - " + id);
            return null;
View Full Code Here

       
        buf.readUnsignedByte(); // command
        int length = buf.readUnsignedByte();
       
        // Parse message
        String sentence = buf.readBytes(length).toString(Charset.defaultCharset());
        Matcher parser = pattern.matcher(sentence);
        if (!parser.matches()) {
            return null;
        }
       
View Full Code Here

                    result, 0, result.readableBytes(), "$");
            if (beginIndex == null) {
                return result;
            } else {
                result.skipBytes(beginIndex);
                return result.readBytes(result.readableBytes());
            }

        }

        return null;
View Full Code Here

                if (outputStream == null) {
                    awaitingEvents.add(e);
                    return;
                }
                b = new byte[buffer.readableBytes()];
                buffer.readBytes(b);
                outputStream.write(b);
                outputStream.flush();
                e.getFuture().setSuccess();
            }
            catch (IOException e1) {
View Full Code Here

            this.outputStream = outputStream;
            connected = true;
            for (MessageEvent awaitingEvent : awaitingEvents) {
                ChannelBuffer buffer = (ChannelBuffer) awaitingEvent.getMessage();
                byte[] b = new byte[buffer.readableBytes()];
                buffer.readBytes(b);
                try {
                    outputStream.write(b);
                    outputStream.flush();
                    awaitingEvent.getFuture().setSuccess();
                }
View Full Code Here

        response.setContentLength(length);
        response.setStatus(HttpServletResponse.SC_OK);
        for (MessageEvent event: buffers) {
            ChannelBuffer buffer = (ChannelBuffer) event.getMessage();
            byte[] b = new byte[buffer.readableBytes()];
            buffer.readBytes(b);
            try {
                response.getOutputStream().write(b);
                event.getFuture().setSuccess();
            } catch (IOException e) {
                event.getFuture().setFailure(e);
View Full Code Here

        if (type == MSG_TYPE_TRACKER_ID_EXT) {
            long id = buf.readUnsignedInt();
            int length = buf.readUnsignedShort();
            buf.skipBytes(length);
            length = buf.readUnsignedShort();
            String imei = buf.readBytes(length).toString(Charset.defaultCharset());
            try {
                deviceId = getDataManager().getDeviceByImei(imei).getId();
                loadLastIndex();
            } catch(Exception error) {
                Log.warning("Unknown device - " + imei + " (id - " + id + ")");
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.