コード例 #1
0
  @Override
  public int read() throws IOException, RemoteException, RemoteException {

    makePayloadDataAvailable();

    if (remaining == 0) {
      return -1;
    }

    remaining--;
    readThisFragment++;

    int masked = processor.read();
    if (masked == -1) {
      return -1;
    }
    return masked ^ (frame.getMask()[(int) ((readThisFragment - 1) % 4)] & 0xFF);
  }
コード例 #2
0
  @Override
  public int read(byte b[], int off, int len) throws IOException, RemoteException, RemoteException {

    makePayloadDataAvailable();

    if (remaining == 0) {
      return -1;
    }

    if (len > remaining) {
      len = (int) remaining;
    }
    int result = processor.read(true, b, off, len);
    if (result == -1) {
      return -1;
    }

    for (int i = off; i < off + result; i++) {
      b[i] = (byte) (b[i] ^ frame.getMask()[(int) ((readThisFragment + i - off) % 4)]);
    }
    remaining -= result;
    readThisFragment += result;
    return result;
  }