SessionListener添加Session注册事件

master
剑器近 2021-07-21 17:58:04 +08:00
parent c869bd2280
commit 166d9971a1
2 changed files with 9 additions and 0 deletions

View File

@ -72,6 +72,8 @@ public class Session {
this.clientId = message.getClientId();
if (sessionManager != null)
sessionManager.add(this);
if (sessionListener != null)
sessionListener.sessionRegistered(this);
}
public boolean isRegistered() {

View File

@ -5,9 +5,16 @@ package io.github.yezhihao.netmc.session;
* home https://gitee.com/yezhihao/jt808-server
*/
public interface SessionListener {
/** 客户端建立连接 */
default void sessionCreated(Session session) {
}
/** 客户端完成注册或鉴权 */
default void sessionRegistered(Session session) {
}
/** 客户端注销或离线 */
default void sessionDestroyed(Session session) {
}
}