diff --git a/src/main/java/io/github/yezhihao/netmc/session/Session.java b/src/main/java/io/github/yezhihao/netmc/session/Session.java index 681527b..918c8f7 100644 --- a/src/main/java/io/github/yezhihao/netmc/session/Session.java +++ b/src/main/java/io/github/yezhihao/netmc/session/Session.java @@ -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() { diff --git a/src/main/java/io/github/yezhihao/netmc/session/SessionListener.java b/src/main/java/io/github/yezhihao/netmc/session/SessionListener.java index 0f1e082..bb9d0b1 100644 --- a/src/main/java/io/github/yezhihao/netmc/session/SessionListener.java +++ b/src/main/java/io/github/yezhihao/netmc/session/SessionListener.java @@ -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) { } } \ No newline at end of file