@Override
  public void sessionClosed(IoSession session) throws Exception {
    com.github.ltsopensource.remoting.Channel channel = new MinaChannel(session);

    final String remoteAddress = RemotingHelper.parseChannelRemoteAddr(channel);
    LOGGER.info("{}: sessionClosed, the channel[{}]", sideType, remoteAddress);

    if (remoting.getChannelEventListener() != null) {
      remoting.putRemotingEvent(new RemotingEvent(RemotingEventType.CLOSE, remoteAddress, channel));
    }
  }
  @Override
  public void exceptionCaught(IoSession session, Throwable cause) throws Exception {
    com.github.ltsopensource.remoting.Channel channel = new MinaChannel(session);

    final String remoteAddress = RemotingHelper.parseChannelRemoteAddr(channel);
    LOGGER.warn("{}: exceptionCaught {}. ", sideType, remoteAddress, cause);

    if (remoting.getChannelEventListener() != null) {
      remoting.putRemotingEvent(
          new RemotingEvent(RemotingEventType.EXCEPTION, remoteAddress, channel));
    }

    RemotingHelper.closeChannel(channel);
  }
  @Override
  public void sessionIdle(IoSession session, IdleStatus status) throws Exception {
    com.github.ltsopensource.remoting.Channel channel = new MinaChannel(session);

    final String remoteAddress = RemotingHelper.parseChannelRemoteAddr(channel);

    if (IdleStatus.BOTH_IDLE == status) {
      LOGGER.info("{}: IDLE [{}]", sideType, remoteAddress);
      RemotingHelper.closeChannel(channel);
    }

    if (remoting.getChannelEventListener() != null) {
      RemotingEventType remotingEventType = null;
      if (IdleStatus.BOTH_IDLE == status) {
        remotingEventType = RemotingEventType.ALL_IDLE;
      } else if (IdleStatus.READER_IDLE == status) {
        remotingEventType = RemotingEventType.READER_IDLE;
      } else if (IdleStatus.WRITER_IDLE == status) {
        remotingEventType = RemotingEventType.WRITER_IDLE;
      }
      remoting.putRemotingEvent(new RemotingEvent(remotingEventType, remoteAddress, channel));
    }
  }