Search in sources :

Example 1 with EzyUserRemovedEvent

use of com.tvd12.ezyfoxserver.event.EzyUserRemovedEvent in project ezyfox-server by youngmonkeys.

the class EzyDisconnectEventImplTest method test.

@Test
public void test() {
    EzyUser user = newUser();
    EzyUserRemovedEvent event = new EzySimpleUserRemovedEvent(user, EzyDisconnectReason.IDLE);
    assert event.getUser() == user;
    assert event.getReason() == EzyDisconnectReason.IDLE;
}
Also used : EzyUser(com.tvd12.ezyfoxserver.entity.EzyUser) EzyUserRemovedEvent(com.tvd12.ezyfoxserver.event.EzyUserRemovedEvent) EzySimpleUserRemovedEvent(com.tvd12.ezyfoxserver.event.EzySimpleUserRemovedEvent) BaseCoreTest(com.tvd12.ezyfoxserver.testing.BaseCoreTest) Test(org.testng.annotations.Test)

Example 2 with EzyUserRemovedEvent

use of com.tvd12.ezyfoxserver.event.EzyUserRemovedEvent in project ezyfox-server by youngmonkeys.

the class EzySocketUserRemovalHandler method processUserRemoval.

private void processUserRemoval(EzySocketUserRemoval removal) {
    try {
        EzyUser user = removal.getUser();
        try {
            EzyConstant reason = removal.getReason();
            EzyZoneContext zoneContext = removal.getZoneContext();
            EzyUserRemovedEvent event = newUserRemovedEvent(user, reason);
            removeUserFromApps(zoneContext, event);
            notifyUserRemovedToPlugins(zoneContext, event);
        } finally {
            user.destroy();
        }
        logger.debug("user {} has destroyed", user);
    } finally {
        removal.release();
    }
}
Also used : EzyUser(com.tvd12.ezyfoxserver.entity.EzyUser) EzyZoneContext(com.tvd12.ezyfoxserver.context.EzyZoneContext) EzyConstant(com.tvd12.ezyfox.constant.EzyConstant) EzyUserRemovedEvent(com.tvd12.ezyfoxserver.event.EzyUserRemovedEvent)

Example 3 with EzyUserRemovedEvent

use of com.tvd12.ezyfoxserver.event.EzyUserRemovedEvent in project ezyfox-server by youngmonkeys.

the class EzySocketUserRemovalHandler method removeUserFromApp.

protected void removeUserFromApp(EzyAppContext appContext, EzyUserRemovedEvent event) {
    EzyUser user = event.getUser();
    EzyApplication app = appContext.getApp();
    EzyAppUserManager userManager = app.getUserManager();
    try {
        boolean contains = userManager.containsUser(user);
        if (contains) {
            userManager.removeUser(user, event.getReason());
        }
    } catch (Exception e) {
        String appName = app.getSetting().getName();
        logger.error("remove user: {} from app: {} error", event.getUser(), appName, e);
    }
}
Also used : EzyUser(com.tvd12.ezyfoxserver.entity.EzyUser) EzyApplication(com.tvd12.ezyfoxserver.EzyApplication) EzyAppUserManager(com.tvd12.ezyfoxserver.wrapper.EzyAppUserManager) EzyProcessor.processWithLogException(com.tvd12.ezyfox.util.EzyProcessor.processWithLogException)

Aggregations

EzyUser (com.tvd12.ezyfoxserver.entity.EzyUser)3 EzyUserRemovedEvent (com.tvd12.ezyfoxserver.event.EzyUserRemovedEvent)2 EzyConstant (com.tvd12.ezyfox.constant.EzyConstant)1 EzyProcessor.processWithLogException (com.tvd12.ezyfox.util.EzyProcessor.processWithLogException)1 EzyApplication (com.tvd12.ezyfoxserver.EzyApplication)1 EzyZoneContext (com.tvd12.ezyfoxserver.context.EzyZoneContext)1 EzySimpleUserRemovedEvent (com.tvd12.ezyfoxserver.event.EzySimpleUserRemovedEvent)1 BaseCoreTest (com.tvd12.ezyfoxserver.testing.BaseCoreTest)1 EzyAppUserManager (com.tvd12.ezyfoxserver.wrapper.EzyAppUserManager)1 Test (org.testng.annotations.Test)1