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 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);
    }
  }
 public ByteBuffer prepareAppDataBuffer() {
   return ByteBufferFactory.getInstance().allocateDirect(appBufferMax);
 }
 public ByteBuffer prepareEncryptedDataBuffer() {
   return ByteBufferFactory.getInstance().allocateDirect(netBufferMax);
 }