public void sendPacket(Packet packet) throws IOException {
    if (packet == null) {
      log.error("Packet is null,please check synchronize");
      return;
    }

    if (channelContext.getId() == null) {
      log.error("target socketChannelId is null!");
      return;
    }

    byte[] bytes = null;
    try {
      bytes = channelContext.getPacketHandler().onSend(packet, channelContext);
    } catch (Exception e) {
      log.error(e.getMessage(), e);
      return;
    }

    if (log.isDebugEnabled()) {
      log.debug("send:{}{}", Arrays.toString(bytes), packet);
    }

    if (bytes != null) {
      sendData(bytes, channelContext.getSocketChannel());

    } else {
      log.error("bytes is null");
    }
  }