コード例 #1
0
  @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));
    }
  }
コード例 #2
0
  @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);
  }
コード例 #3
0
  @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));
    }
  }
コード例 #4
0
 @Override
 public void messageReceived(IoSession session, Object message) throws Exception {
   if (message != null && message instanceof RemotingCommand) {
     remoting.processMessageReceived(new MinaChannel(session), (RemotingCommand) message);
   }
 }