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;
}
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();
}
}
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);
}
}
Aggregations