From d87f125f2023bd71f1caaae684e75199027d75d2 Mon Sep 17 00:00:00 2001 From: Ta Van Dung Date: Fri, 22 Nov 2024 22:38:07 +0700 Subject: [PATCH] version 1.2.9: add USER_EXITED_APP_EVENT (#131) --- ezyfox-server-boot/pom.xml | 2 +- ezyfox-server-core/pom.xml | 2 +- .../tvd12/ezyfoxserver/constant/EzyEventNames.java | 1 + .../tvd12/ezyfoxserver/constant/EzyEventType.java | 3 ++- .../controller/EzyExitAppController.java | 9 ++++++++- .../tvd12/ezyfoxserver/entity/EzySimpleUser.java | 2 +- .../event/EzySimpleUserExitedAppEvent.java | 14 ++++++++++++++ .../ezyfoxserver/event/EzyUserExitedAppEvent.java | 3 +++ ezyfox-server-embedded/pom.xml | 2 +- ezyfox-server-nio/pom.xml | 4 ++-- ezyfox-server-niorunner/pom.xml | 2 +- ezyfox-server-support/pom.xml | 2 +- pom.xml | 4 ++-- 13 files changed, 38 insertions(+), 12 deletions(-) create mode 100644 ezyfox-server-core/src/main/java/com/tvd12/ezyfoxserver/event/EzySimpleUserExitedAppEvent.java create mode 100644 ezyfox-server-core/src/main/java/com/tvd12/ezyfoxserver/event/EzyUserExitedAppEvent.java diff --git a/ezyfox-server-boot/pom.xml b/ezyfox-server-boot/pom.xml index f54ef843..015c4734 100644 --- a/ezyfox-server-boot/pom.xml +++ b/ezyfox-server-boot/pom.xml @@ -4,7 +4,7 @@ com.tvd12 ezyfox-server - 1.2.8.2 + 1.2.9 ezyfox-server-boot diff --git a/ezyfox-server-core/pom.xml b/ezyfox-server-core/pom.xml index e5574bbe..dabacbb4 100644 --- a/ezyfox-server-core/pom.xml +++ b/ezyfox-server-core/pom.xml @@ -6,7 +6,7 @@ com.tvd12 ezyfox-server - 1.2.8.2 + 1.2.9 ezyfox-server-core ezyfox-server-core diff --git a/ezyfox-server-core/src/main/java/com/tvd12/ezyfoxserver/constant/EzyEventNames.java b/ezyfox-server-core/src/main/java/com/tvd12/ezyfoxserver/constant/EzyEventNames.java index 6db7eb84..82ffcdde 100644 --- a/ezyfox-server-core/src/main/java/com/tvd12/ezyfoxserver/constant/EzyEventNames.java +++ b/ezyfox-server-core/src/main/java/com/tvd12/ezyfoxserver/constant/EzyEventNames.java @@ -8,6 +8,7 @@ public final class EzyEventNames { public static final String USER_LOGIN = "USER_LOGIN"; public static final String USER_ACCESS_APP = "USER_ACCESS_APP"; public static final String USER_ACCESSED_APP = "USER_ACCESSED_APP"; + public static final String USER_EXITED_APP = "USER_EXITED_APP"; public static final String USER_ADDED = "USER_ADDED"; public static final String USER_REMOVED = "USER_REMOVED"; public static final String SESSION_REMOVED = "SESSION_REMOVED"; diff --git a/ezyfox-server-core/src/main/java/com/tvd12/ezyfoxserver/constant/EzyEventType.java b/ezyfox-server-core/src/main/java/com/tvd12/ezyfoxserver/constant/EzyEventType.java index 67e1a828..41a94ecc 100644 --- a/ezyfox-server-core/src/main/java/com/tvd12/ezyfoxserver/constant/EzyEventType.java +++ b/ezyfox-server-core/src/main/java/com/tvd12/ezyfoxserver/constant/EzyEventType.java @@ -3,6 +3,7 @@ import com.tvd12.ezyfox.constant.EzyConstant; import lombok.Getter; +@Getter public enum EzyEventType implements EzyConstant { SERVER_INITIALIZING(0), @@ -13,10 +14,10 @@ public enum EzyEventType implements EzyConstant { USER_ADDED(26), USER_REMOVED(27), USER_ACCESSED_APP(28), + USER_EXITED_APP(29), SESSION_REMOVED(35), STREAMING(36); - @Getter private final int id; EzyEventType(int id) { diff --git a/ezyfox-server-core/src/main/java/com/tvd12/ezyfoxserver/controller/EzyExitAppController.java b/ezyfox-server-core/src/main/java/com/tvd12/ezyfoxserver/controller/EzyExitAppController.java index 5ca4307a..082993ab 100644 --- a/ezyfox-server-core/src/main/java/com/tvd12/ezyfoxserver/controller/EzyExitAppController.java +++ b/ezyfox-server-core/src/main/java/com/tvd12/ezyfoxserver/controller/EzyExitAppController.java @@ -1,9 +1,13 @@ package com.tvd12.ezyfoxserver.controller; import com.tvd12.ezyfoxserver.EzyApplication; +import com.tvd12.ezyfoxserver.constant.EzyEventType; import com.tvd12.ezyfoxserver.constant.EzyUserRemoveReason; import com.tvd12.ezyfoxserver.context.EzyAppContext; import com.tvd12.ezyfoxserver.context.EzyServerContext; +import com.tvd12.ezyfoxserver.entity.EzyUser; +import com.tvd12.ezyfoxserver.event.EzySimpleUserExitedAppEvent; +import com.tvd12.ezyfoxserver.event.EzyUserExitedAppEvent; import com.tvd12.ezyfoxserver.request.EzyExitAppRequest; import com.tvd12.ezyfoxserver.wrapper.EzyAppUserManager; @@ -17,6 +21,9 @@ public void handle(EzyServerContext ctx, EzyExitAppRequest request) { EzyAppContext appContext = ctx.getAppContext(appId); EzyApplication app = appContext.getApp(); EzyAppUserManager userManager = app.getUserManager(); - userManager.removeUser(request.getUser(), EzyUserRemoveReason.EXIT_APP); + EzyUser user = request.getUser(); + userManager.removeUser(user, EzyUserRemoveReason.EXIT_APP); + EzyUserExitedAppEvent event = new EzySimpleUserExitedAppEvent(user); + appContext.handleEvent(EzyEventType.USER_EXITED_APP, event); } } diff --git a/ezyfox-server-core/src/main/java/com/tvd12/ezyfoxserver/entity/EzySimpleUser.java b/ezyfox-server-core/src/main/java/com/tvd12/ezyfoxserver/entity/EzySimpleUser.java index 16b770c9..dc7a6840 100644 --- a/ezyfox-server-core/src/main/java/com/tvd12/ezyfoxserver/entity/EzySimpleUser.java +++ b/ezyfox-server-core/src/main/java/com/tvd12/ezyfoxserver/entity/EzySimpleUser.java @@ -38,7 +38,7 @@ public class EzySimpleUser @Setter(AccessLevel.NONE) protected Map sessionMap = new ConcurrentHashMap<>(); - private static final transient AtomicLong COUNTER = new AtomicLong(0); + private static final AtomicLong COUNTER = new AtomicLong(0); @Override public void addSession(EzySession session) { diff --git a/ezyfox-server-core/src/main/java/com/tvd12/ezyfoxserver/event/EzySimpleUserExitedAppEvent.java b/ezyfox-server-core/src/main/java/com/tvd12/ezyfoxserver/event/EzySimpleUserExitedAppEvent.java new file mode 100644 index 00000000..3d1b5b85 --- /dev/null +++ b/ezyfox-server-core/src/main/java/com/tvd12/ezyfoxserver/event/EzySimpleUserExitedAppEvent.java @@ -0,0 +1,14 @@ +package com.tvd12.ezyfoxserver.event; + +import com.tvd12.ezyfoxserver.entity.EzyUser; +import lombok.Getter; + +@Getter +public class EzySimpleUserExitedAppEvent + extends EzySimpleUserEvent + implements EzyUserExitedAppEvent { + + public EzySimpleUserExitedAppEvent(EzyUser user) { + super(user); + } +} diff --git a/ezyfox-server-core/src/main/java/com/tvd12/ezyfoxserver/event/EzyUserExitedAppEvent.java b/ezyfox-server-core/src/main/java/com/tvd12/ezyfoxserver/event/EzyUserExitedAppEvent.java new file mode 100644 index 00000000..6d82a138 --- /dev/null +++ b/ezyfox-server-core/src/main/java/com/tvd12/ezyfoxserver/event/EzyUserExitedAppEvent.java @@ -0,0 +1,3 @@ +package com.tvd12.ezyfoxserver.event; + +public interface EzyUserExitedAppEvent extends EzyUserEvent {} diff --git a/ezyfox-server-embedded/pom.xml b/ezyfox-server-embedded/pom.xml index 0a9473f6..c432d2ee 100755 --- a/ezyfox-server-embedded/pom.xml +++ b/ezyfox-server-embedded/pom.xml @@ -5,7 +5,7 @@ com.tvd12 ezyfox-server - 1.2.8.2 + 1.2.9 ezyfox-server-embedded diff --git a/ezyfox-server-nio/pom.xml b/ezyfox-server-nio/pom.xml index b14b2407..6d8deccb 100755 --- a/ezyfox-server-nio/pom.xml +++ b/ezyfox-server-nio/pom.xml @@ -5,7 +5,7 @@ com.tvd12 ezyfox-server - 1.2.8.2 + 1.2.9 ezyfox-server-nio @@ -13,7 +13,7 @@ https://youngmonkeys.org/project/ezyfox-sever/ - 9.4.50.v20221201 + 9.4.56.v20240826 diff --git a/ezyfox-server-niorunner/pom.xml b/ezyfox-server-niorunner/pom.xml index 583887b8..836478d6 100755 --- a/ezyfox-server-niorunner/pom.xml +++ b/ezyfox-server-niorunner/pom.xml @@ -5,7 +5,7 @@ com.tvd12 ezyfox-server - 1.2.8.2 + 1.2.9 ezyfox-server-niorunner diff --git a/ezyfox-server-support/pom.xml b/ezyfox-server-support/pom.xml index f3aa1d30..da851703 100644 --- a/ezyfox-server-support/pom.xml +++ b/ezyfox-server-support/pom.xml @@ -4,7 +4,7 @@ com.tvd12 ezyfox-server - 1.2.8.2 + 1.2.9 ezyfox-server-support ezyfox-server-support diff --git a/pom.xml b/pom.xml index 6206a8cb..792279ee 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ 1.0.6 ezyfox-server - 1.2.8.2 + 1.2.9 pom ezyfox-server @@ -57,7 +57,7 @@ - 1.2.8 + 1.2.9 2.1.7