public interface NetMonitor
bus-socket并未单独提供配置监控服务的接口,用户在使用时仅需在MessageProcessor实现类中同时实现当前NetMonitor接口即可。 在注册消息处理器时,若服务监测到该处理器同时实现了NetMonitor接口,则该监视器便会生效。
public class MessageProcessorImpl implements MessageProcessor,NetMonitor{
}
注意:
实现本接口时要关注acceptMonitor接口的返回值,如无特殊需求直接返回true,若返回false会拒绝本次连接。
非必要情况下请勿使用该接口,未来可能会调整接口设计| Modifier and Type | Method and Description |
|---|---|
void |
afterRead(AioSession session,
int readSize)
监控触发本次读回调Session的已读数据字节数
|
void |
afterWrite(AioSession session,
int writeSize)
监控触发本次写回调session的已写数据字节数
|
void |
beforeRead(AioSession session)
即将开始读取数据
|
void |
beforeWrite(AioSession session)
即将开始写数据
|
AsynchronousSocketChannel |
shouldAccept(AsynchronousSocketChannel channel)
监控已接收到的连接
|
AsynchronousSocketChannel shouldAccept(AsynchronousSocketChannel channel)
channel - 当前已经建立连接的通道对象void afterRead(AioSession session, int readSize)
session - 当前执行read的AioSession对象readSize - 已读数据长度void beforeRead(AioSession session)
session - 当前会话对象void afterWrite(AioSession session, int writeSize)
session - 本次执行write回调的AIOSession对象writeSize - 本次输出的数据长度void beforeWrite(AioSession session)
session - 当前会话对象Copyright © 2021. All rights reserved.