public void sendHttpMessage(
      final byte message[],
      final InetAddress receiverAddress,
      final int receiverPort,
      final boolean retry)
      throws IOException {
    checkSocketState();

    ByteBuffer b = ByteBuffer.wrap(message);
    try {
      sslStateMachine.wrap(
          b,
          ByteBufferFactory.getInstance().allocateDirect(netBufferMax),
          new MessageSendCallback() {

            @Override
            public void doSend(byte[] bytes) throws IOException {
              NioTlsWebSocketMessageChannel.super.sendMessage(
                  bytes, receiverAddress, receiverPort, retry);
            }
          });
    } catch (IOException e) {
      throw e;
    }
  }
 @Override
 protected void addBytes(byte[] bytes) throws Exception {
   if (logger.isLoggingEnabled(LogWriter.TRACE_DEBUG)) {
     logger.logDebug("Adding WSS bytes for decryption " + bytes.length);
   }
   if (bytes.length <= 0) return;
   ByteBuffer buffer = ByteBuffer.wrap(bytes);
   sslStateMachine.unwrap(buffer);
 }
  @Override
  protected void sendMessage(final byte[] msg, final boolean isClient) throws IOException {
    checkSocketState();

    ByteBuffer b = ByteBuffer.wrap(msg);
    try {
      sslStateMachine.wrap(
          b,
          ByteBufferFactory.getInstance().allocateDirect(netBufferMax),
          new MessageSendCallback() {

            @Override
            public void doSend(byte[] bytes) throws IOException {

              NioTlsWebSocketMessageChannel.super.sendMessage(bytes, isClient);
            }
          });
    } catch (Exception e) {
      throw new IOException("Can't send message", e);
    }
  }