Package org.chromium.sdk.internal.websocket.ManualLoggingSocketWrapper

Examples of org.chromium.sdk.internal.websocket.ManualLoggingSocketWrapper.LoggableOutput


  }

  private void sendMessage(int opCode, LoggablePayload loggablePayload, boolean isClosingMessage)
      throws IOException {
    int length = loggablePayload.getLength();
    LoggableOutput output = getSocketWrapper().getLoggableOutput();

    byte[] maskBytes = maskStrategy.generate();

    synchronized (this) {
      if (isOutputClosed()) {
        throw new IOException("WebSocket is already closed for output");
      }

      byte firstByte = (byte) (FrameBits.FIN_BIT | OpCode.TEXT);

      output.writeByte(firstByte);

      int maskFlag = maskBytes == null ? 0 : FrameBits.MASK_BIT;

      if (length <= 125) {
        output.writeByte((byte) (length | maskFlag));
      } else if (length <= FrameBits.MAX_TWO_BYTE_INT) {
        output.writeByte((byte) (FrameBits.LENGTH_2_BYTE_CODE | maskFlag));
        output.writeByte((byte) ((length >> 8) & 0xFF));
        output.writeByte((byte) (length & 0xFF));
      } else {
        output.writeByte((byte) (FrameBits.LENGTH_8_BYTE_CODE | maskFlag));
        output.writeByte((byte) 0);
        output.writeByte((byte) 0);
        output.writeByte((byte) 0);
        output.writeByte((byte) 0);
        output.writeByte((byte) (length >>> 24));
        output.writeByte((byte) ((length >> 16) & 0xFF));
        output.writeByte((byte) ((length >> 8) & 0xFF));
        output.writeByte((byte) (length & 0xFF));
      }

      if (maskBytes != null) {
        output.writeBytes(maskBytes);
      }
      loggablePayload.send(output, maskBytes);

      if (isClosingMessage) {
        setOutputClosed(true);
      }
    }

    output.markSeparatorForLog();
  }
View Full Code Here


  }

  private void sendMessage(int opCode, LoggablePayload loggablePayload, boolean isClosingMessage)
      throws IOException {
    int length = loggablePayload.getLength();
    LoggableOutput output = getSocketWrapper().getLoggableOutput();

    byte[] maskBytes = maskStrategy.generate();

    synchronized (this) {
      if (isOutputClosed()) {
        throw new IOException("WebSocket is already closed for output");
      }

      if (isClosingMessage) {
        // Close it before actually sending, because we can fail on it.
        setOutputClosed(true);
      }

      byte firstByte = (byte) (FrameBits.FIN_BIT | OpCode.TEXT);

      output.writeByte(firstByte);

      int maskFlag = maskBytes == null ? 0 : FrameBits.MASK_BIT;

      if (length <= 125) {
        output.writeByte((byte) (length | maskFlag));
      } else if (length <= FrameBits.MAX_TWO_BYTE_INT) {
        output.writeByte((byte) (FrameBits.LENGTH_2_BYTE_CODE | maskFlag));
        output.writeByte((byte) ((length >> 8) & 0xFF));
        output.writeByte((byte) (length & 0xFF));
      } else {
        output.writeByte((byte) (FrameBits.LENGTH_8_BYTE_CODE | maskFlag));
        output.writeByte((byte) 0);
        output.writeByte((byte) 0);
        output.writeByte((byte) 0);
        output.writeByte((byte) 0);
        output.writeByte((byte) (length >>> 24));
        output.writeByte((byte) ((length >> 16) & 0xFF));
        output.writeByte((byte) ((length >> 8) & 0xFF));
        output.writeByte((byte) (length & 0xFF));
      }

      if (maskBytes != null) {
        output.writeBytes(maskBytes);
      }
      loggablePayload.send(output, maskBytes);
    }

    output.markSeparatorForLog();
  }
View Full Code Here

      };
    }

    @Override
    public LoggableOutput wrapOutputStream(final OutputStream outputStream) {
      return new LoggableOutput() {
        @Override public void writeAsciiString(String string) throws IOException {
          outputStream.write(string.getBytes(UTF_8_CHARSET));
        }
        @Override public void writeByte(byte b) throws IOException {
          outputStream.write(b);
View Full Code Here

TOP

Related Classes of org.chromium.sdk.internal.websocket.ManualLoggingSocketWrapper.LoggableOutput

Copyright © 2018 www.massapicom. 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.