From 166d9971a1db1f8d291df37bb58e2b9f30f5160b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=89=91=E5=99=A8=E8=BF=91?= Date: Wed, 21 Jul 2021 17:58:04 +0800 Subject: [PATCH] =?UTF-8?q?SessionListener=E6=B7=BB=E5=8A=A0Session?= =?UTF-8?q?=E6=B3=A8=E5=86=8C=E4=BA=8B=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/github/yezhihao/netmc/session/Session.java | 2 ++ .../io/github/yezhihao/netmc/session/SessionListener.java | 7 +++++++ 2 files changed, 9 insertions(+) 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