Ejemplo n.º 1
0
  @Override
  public void onMessageReceived(IChannel channel, I inMsg) {
    // failed to reschedule, channel timed out
    if (!scheduleIdleTimeout(channel)) return;

    final ISessionListener<I, O> listener = m_listener;
    if (listener != null) listener.onMessageReceived(channel, inMsg);
  }
Ejemplo n.º 2
0
  @Override
  public void onChannelIdleTimedOut(IChannel channel) {
    try {
      c_logger.debug("{}: IDLE_TIMEOUT", channel);

      final ISessionListener<I, O> listener = m_listener;
      if (listener != null) listener.onSessionIdleTimedOut(channel);
    } finally {
      channel.close();
    }
  }
Ejemplo n.º 3
0
  @Override
  public void onChannelException(IChannel channel, Throwable t) {
    try {
      c_logger.error(
          StrUtil.join(channel, "(remoteAddr=", channel.remoteAddress(), ") got an error"), t);

      final ISessionListener<I, O> listener = m_listener;
      if (listener != null) listener.onSessionException(channel, t);
    } catch (Throwable e) {
      c_logger.error(
          StrUtil.join(channel, "(remoteAddr=", channel.remoteAddress(), ") Unexpected Error: "),
          e);
    } finally {
      channel.close();
    }
  }
Ejemplo n.º 4
0
  @Override
  public void onChannelClosed(IChannel channel) {
    c_logger.debug("{}(remoteAddr={}): CLOSED", channel, channel.remoteAddress());

    final ConcurrentHashMap<Long, IChannel> channels = m_channels;
    if (channels != null) channels.remove(channel.id());

    final ISessionListener<I, O> listener = m_listener;
    if (listener != null) {
      try {
        listener.onSessionClosed(channel);
      } catch (Throwable t) {
        c_logger.error(
            StrUtil.join(channel, "(remoteAddr=", channel.remoteAddress(), ") Unexpected Error: "),
            t);
      }
    }
  }
Ejemplo n.º 5
0
  @Override
  public void onChannelOpened(IChannel channel) {
    c_logger.debug("{}(remoteAddr={}): OPENED", channel, channel.remoteAddress());

    final Long id = channel.id();
    final ConcurrentHashMap<Long, IChannel> channels = m_channels;
    if (channels != null) channels.put(id, channel);

    if (m_stopped) {
      channel.close();
      return;
    }

    // failed to schedule, channel has been closed
    if (!scheduleIdleTimeout(channel)) return;

    final ISessionListener<I, O> listener = m_listener;
    if (listener != null) listener.onSessionOpened(channel);
  }
Ejemplo n.º 6
0
 @Override
 public void onMessageSent(IChannel channel, O outMsg) {
   final ISessionListener<I, O> listener = m_listener;
   if (listener != null) listener.onMessageSent(channel, outMsg);
 }
Ejemplo n.º 7
0
 @Override
 public void beforeSendMessage(IChannel channel, O outMsg) {
   final ISessionListener<I, O> listener = m_listener;
   if (listener != null) listener.beforeSendMessage(channel, outMsg);
 }