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");
    }
  }
  public void removeConnection(ChannelContext channelContext) {
    List<ChannelContext> set = mapOfProtocolAndChannelContexts.get(channelContext.getProtocol());

    if (set != null) {
      log.warn("remove channelContext:{}", channelContext.getId());
      set.remove(channelContext);
    }
  }
 /** @param socketChannelId */
 public SendRunnable(ChannelContext channelContext) {
   this.channelContext = channelContext;
   super.setRunnableName(SendRunnable.class.getSimpleName() + " [" + channelContext.getId() + "]");
 }