Ejemplo n.º 1
0
 @Override
 public void writeBlock(Channel channel, byte[] bytes) throws IOException {
   try {
     boolean hasMore;
     int pos = 0;
     do {
       int frame =
           Math.min(transportFrameSize, bytes.length - pos); // # of bytes we send in this chunk
       hasMore = frame + pos < bytes.length;
       wb.write(ChunkHeader.pack(frame, hasMore));
       wb.write(bytes, pos, frame);
       scheduleReregister();
       pos += frame;
     } while (hasMore);
   } catch (InterruptedException e) {
     throw (InterruptedIOException) new InterruptedIOException().initCause(e);
   }
 }