use of com.tvd12.ezyfoxserver.client.entity.EzyUser in project ezyfox-server by youngmonkeys.
the class EzyZoneUserManagerImpl method unmapSessionUser.
@Override
public void unmapSessionUser(EzySession session, EzyConstant reason) {
EzyUser user = usersBySession.remove(session);
if (user != null) {
user.removeSession(session);
logger.debug("zone: {} remove session {} from user {} by reason {}, " + "user remain: {} sessions, usersBySession.size: {}", zoneName, session.getClientAddress(), user, reason, user.getSessionCount(), usersBySession.size());
if (shouldRemoveUserNow(user)) {
removeUser(user, reason);
}
}
}
use of com.tvd12.ezyfoxserver.client.entity.EzyUser 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.client.entity.EzyUser 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);
}
}
use of com.tvd12.ezyfoxserver.client.entity.EzyUser in project ezyfox-server by youngmonkeys.
the class EzyAbstractUserManager method addUser.
@Override
public EzyUser addUser(EzyUser user) {
EzyUser answer = doAddUser(user);
logger.info("{} add user: {}, locks.size = {}, usersById.size = {}, usersByName.size = {}", getMessagePrefix(), user, locks.size(), usersById.size(), usersByName.size());
return answer;
}
use of com.tvd12.ezyfoxserver.client.entity.EzyUser in project ezyfox-server by youngmonkeys.
the class EzyUserManagerImplTest method test.
@Test
public void test() {
MyTestUserManager manager = MyTestUserManager.builder().build();
MyTestSession session = new MyTestSession();
session.setId(10);
MyTestUser user = new MyTestUser();
user.setId(1);
user.setName("dungtv");
session.setToken("123456");
user.addSession(session);
manager.addUser(session, user);
assert manager.getUser(1) == user;
assert manager.getUser("dungtv") == user;
assert manager.containsUser(1);
assert !manager.containsUser(-1);
assert manager.containsUser(session);
assert manager.containsUser(user);
manager.removeUser(user.getId());
assert manager.getUser(1) == null;
manager.addUser(session, user);
manager.removeUser(user.getName());
assert manager.getUser("dungtv") == null;
manager.addUser(session, user);
manager.removeUser((EzyUser) null);
}
Aggregations