Package org.miaixz.bus.socket
Interface NetMonitor
- All Known Subinterfaces:
Plugin<T>
- All Known Implementing Classes:
AbstractMessageProcessor,AbstractPlugin,BlackListPlugin,BufferPageMonitorPlugin,HeartPlugin,MonitorPlugin,RateLimiterPlugin,ReconnectPlugin,SocketOptionPlugin,SslPlugin,StreamMonitorPlugin
public interface NetMonitor
网络监控器,提供通讯层面监控功能的接口。
bus-socket并未单独提供配置监控服务的接口,用户在使用时仅需在MessageProcessor实现类中同时实现当前NetMonitor接口即可。 在注册消息处理器时,若服务监测到该处理器同时实现了NetMonitor接口,则该监视器便会生效。
示例:
public class MessageProcessorImpl implements MessageProcessor,NetMonitor{
}
注意:
实现本接口时要关注acceptMonitor接口的返回值,如无特殊需求直接返回true,若返回false会拒绝本次连接。
非必要情况下请勿使用该接口,未来可能会调整接口设计- Since:
- Java 17+
- Author:
- Kimi Liu
-
Method Summary
Modifier and TypeMethodDescriptionvoidafterRead(AioSession session, int readSize) 监控触发本次读回调Session的已读数据字节数voidafterWrite(AioSession session, int writeSize) 监控触发本次写回调session的已写数据字节数voidbeforeRead(AioSession session) 即将开始读取数据voidbeforeWrite(AioSession session) 即将开始写数据shouldAccept(AsynchronousSocketChannel channel) 监控已接收到的连接
-
Method Details
-
shouldAccept
监控已接收到的连接
- Parameters:
channel- 当前已经建立连接的通道对象- Returns:
- 非null:接受该连接,null:拒绝该连接
-
afterRead
监控触发本次读回调Session的已读数据字节数- Parameters:
session- 当前执行read的AioSession对象readSize- 已读数据长度
-
beforeRead
即将开始读取数据- Parameters:
session- 当前会话对象
-
afterWrite
监控触发本次写回调session的已写数据字节数- Parameters:
session- 本次执行write回调的AIOSession对象writeSize- 本次输出的数据长度
-
beforeWrite
即将开始写数据- Parameters:
session- 当前会话对象
-