@Override
  protected void sendNonWebSocketMessage(byte[] msg, boolean isClient) throws IOException {

    if (logger.isLoggingEnabled(LogWriter.TRACE_DEBUG)) {
      logger.logDebug("sendMessage isClient  = " + isClient + " this = " + this);
    }
    lastActivityTimeStamp = System.currentTimeMillis();

    NIOHandler nioHandler = ((NioTcpMessageProcessor) messageProcessor).nioHandler;
    if (this.socketChannel != null
        && this.socketChannel.isConnected()
        && this.socketChannel.isOpen()) {
      nioHandler.putSocket(NIOHandler.makeKey(this.peerAddress, this.peerPort), this.socketChannel);
    }
    sendMessage(msg, this.peerAddress, this.peerPort, isClient);
  }
 @SuppressWarnings("unchecked")
 @Override
 public void onConnected(Connection con) throws IOException {
   con.setState(Connection.State.connecting);
   String info =
       con.getDirection() == Connection.Direction.in
           ? "remote peer connected to me " + con
           : " connected to remote peer " + con;
   LOGGER.info(info);
   handler.onConnected(con);
 }
  public void sendEncryptedData(byte[] msg) throws IOException {
    // bypass the encryption for already encrypted data or TLS metadata
    if (logger.isLoggingEnabled(LogWriter.TRACE_DEBUG)) {
      logger.logDebug(
          "sendEncryptedData "
              + " this = "
              + this
              + " peerPort = "
              + peerPort
              + " addr = "
              + peerAddress);
    }
    lastActivityTimeStamp = System.currentTimeMillis();

    NIOHandler nioHandler = ((NioTcpMessageProcessor) messageProcessor).nioHandler;
    if (this.socketChannel != null
        && this.socketChannel.isConnected()
        && this.socketChannel.isOpen()) {
      nioHandler.putSocket(NIOHandler.makeKey(this.peerAddress, this.peerPort), this.socketChannel);
    }
    super.sendNonWebSocketMessage(msg, false);
    // super.sendMessage(msg, this.peerAddress, this.peerPort, true);
  }
 @SuppressWarnings("unchecked")
 @Override
 public void onClosed(Connection con, String reason) {
   handler.onClosed(con, reason);
 }
 @SuppressWarnings("unchecked")
 @Override
 public void handle(Connection con, ByteBuffer data, int start, int readeLength) {
   handler.handle(con, data, start, readeLength);
 }
 @SuppressWarnings("unchecked")
 @Override
 public void onConnectFailed(Connection con, Throwable e) {
   LOGGER.warn("connection failed: " + e + " con " + con);
   handler.onConnectFailed(con, e);
 }