Module bus.socket

Class AbstractMessageHandler<T>

java.lang.Object
org.miaixz.bus.socket.metric.handler.AbstractMessageHandler<T>
All Implemented Interfaces:
Handler<T>, Monitor

public abstract class AbstractMessageHandler<T> extends Object implements Handler<T>, Monitor
抽象消息处理
Since:
Java 17+
Author:
Kimi Liu
  • Constructor Details

    • AbstractMessageHandler

      public AbstractMessageHandler()
  • Method Details

    • afterRead

      public final void afterRead(Session session, int readSize)
      Description copied from interface: Monitor
      监控触发本次读回调Session的已读数据字节数
      Specified by:
      afterRead in interface Monitor
      Parameters:
      session - 当前执行read的Session对象
      readSize - 已读数据长度
    • afterWrite

      public final void afterWrite(Session session, int writeSize)
      Description copied from interface: Monitor
      监控触发本次写回调session的已写数据字节数
      Specified by:
      afterWrite in interface Monitor
      Parameters:
      session - 本次执行write回调的Session对象
      writeSize - 本次输出的数据长度
    • beforeRead

      public final void beforeRead(Session session)
      Description copied from interface: Monitor
      即将开始读取数据
      Specified by:
      beforeRead in interface Monitor
      Parameters:
      session - 当前会话对象
    • beforeWrite

      public final void beforeWrite(Session session)
      Description copied from interface: Monitor
      即将开始写数据
      Specified by:
      beforeWrite in interface Monitor
      Parameters:
      session - 当前会话对象
    • shouldAccept

      public final AsynchronousSocketChannel shouldAccept(AsynchronousSocketChannel channel)
      Description copied from interface: Monitor
      监控已接收到的连接
      Specified by:
      shouldAccept in interface Monitor
      Parameters:
      channel - 当前已经建立连接的通道对象
      Returns:
      非null:接受该连接,null:拒绝该连接
    • process

      public final void process(Session session, T data)
      Description copied from interface: Handler
      处理接收到的消息
      Specified by:
      process in interface Handler<T>
      Parameters:
      session - 通信会话
      data - 待处理的业务消息
    • process0

      public abstract void process0(Session session, T data)
      处理接收到的消息
      Parameters:
      session - 会话
      data - 消息信息
      See Also:
    • stateEvent

      public final void stateEvent(Session session, Status status, Throwable throwable)
      Description copied from interface: Handler
      状态机事件,当枚举事件发生时由框架触发该方法
      Specified by:
      stateEvent in interface Handler<T>
      Parameters:
      session - 本次触发状态机的Session对象
      status - 状态枚举
      throwable - 异常对象,如果存在的话
    • stateEvent0

      public abstract void stateEvent0(Session session, Status status, Throwable throwable)
      Parameters:
      session - 会话
      status - 状态
      throwable - 异常
      See Also:
    • addPlugin

      public final void addPlugin(Plugin<T> plugin)