Package org.apache.mina.common

Examples of org.apache.mina.common.ByteBuffer.limit()


        }

        contentHeaderProperties.setDeliveryMode((byte) deliveryMode);
        contentHeaderProperties.setPriority((byte) priority);

        final int size = (payload != null) ? payload.limit() : 0;
        final int contentBodyFrameCount = calculateContentBodyFrameCount(payload);
        final AMQFrame[] frames = new AMQFrame[2 + contentBodyFrameCount];

        if (payload != null)
        {
View Full Code Here


    tag.setDataType(msg.getDataType());
    tag.setTimestamp(timestamp + offset);
    if (msg instanceof IStreamData) {
      ByteBuffer data = ((IStreamData) msg).getData().asReadOnlyBuffer();
      tag.setBodySize(data.limit());
      tag.setBody(data);
    }

    try {
    writer.writeTag(tag);
View Full Code Here

      throws Exception {
    log.debug("Sending response");
    ByteBuffer respBuffer = codecFactory.getSimpleEncoder().encode(null,
        packet);
    final ServletOutputStream out = resp.getOutputStream();
    resp.setContentLength(respBuffer.limit());
    ServletUtils.copy(respBuffer.asInputStream(), out);
    out.flush();
    out.close();
    respBuffer.release();
    respBuffer = null;
View Full Code Here

        try {
          final ServletOutputStream out = resp.getOutputStream();
          ByteBuffer buf = (ByteBuffer) message;
          resp.setStatus(HttpServletResponse.SC_OK);
          resp.setContentType(req.getContentType());
          resp.setContentLength(buf.limit());
          ServletUtils.copy(buf.asInputStream(), out);
          out.flush();
          out.close();
        } catch (IOException e) {
          log.error("Error sending response", e);
View Full Code Here

    for (int i = 0; i < num; i++) {
      chunks[i] = buf.asReadOnlyBuffer();
      final ByteBuffer chunk = chunks[i];
      int position = size * num;
      chunk.position(position);
      if (position + size < chunk.limit()) {
        chunk.limit(position + size);
      }
    }
    return chunks;
  }
View Full Code Here

      chunks[i] = buf.asReadOnlyBuffer();
      final ByteBuffer chunk = chunks[i];
      int position = size * num;
      chunk.position(position);
      if (position + size < chunk.limit()) {
        chunk.limit(position + size);
      }
    }
    return chunks;
  }

View Full Code Here

    params.put("canSeekToEnd", true);
    out.writeMap(params, new Serializer());
    buf.flip();

    if (fileMetaSize == 0) {
      fileMetaSize = buf.limit();
    }

    ITag onMetaData = new Tag(ITag.TYPE_METADATA, 0, fileMetaSize, buf, 0);
    writeTag(onMetaData);
  }
View Full Code Here

    }
    props.put("canSeekToEnd", true);
    out.writeMap(props, new Serializer());
    buf.flip();

    ITag result = new Tag(IoConstants.TYPE_METADATA, 0, buf.limit(), null,
        prevSize);
    result.setBody(buf);
    return result;
  }
View Full Code Here

    if (data.position() != 0) {
      data.flip();
    } else {
      data.rewind();
    }
    header.setSize(data.limit());

    final Header lastHeader = rtmp.getLastWriteHeader(channelId);
    final int headerSize = calculateHeaderSize(header, lastHeader);
   
    rtmp.setLastWriteHeader(channelId, header);
View Full Code Here

    if (log.isDebugEnabled()) {
      log.debug("Returning " + this.pendingMessages.size() + " messages to client.");
    }
    this.noPendingMessages = 0;
    this.pollingDelay = INITIAL_POLLING_DELAY;
    while (result.limit() < targetSize) {
      if (this.pendingMessages.isEmpty()) {
        break;
      }

      synchronized (this.pendingMessages) {
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.