use of com.tvd12.ezyfoxserver.client.event.EzyEvent in project ezyfox-server by youngmonkeys.
the class EzyBroadcastAppsEventImplTest method newAppContext.
private EzyAppContext newAppContext(String appName, EzyEvent event2) {
EzyAppContext appContext = mock(EzyAppContext.class);
EzyApplication app = mock(EzyApplication.class);
when(appContext.getApp()).thenReturn(app);
EzySimpleAppSetting setting = new EzySimpleAppSetting();
setting.setName(appName);
when(app.getSetting()).thenReturn(setting);
EzyAppUserManager appUserManager = EzyAppUserManagerImpl.builder().appName(appName).maxUsers(99).build();
when(app.getUserManager()).thenReturn(appUserManager);
EzySimpleUser user = new EzySimpleUser();
user.setName("user" + appName);
appUserManager.addUser(user);
doThrow(new IllegalStateException()).when(appContext).handleEvent(EzyEventType.SERVER_INITIALIZING, event2);
return appContext;
}
use of com.tvd12.ezyfoxserver.client.event.EzyEvent in project ezyfox-server by youngmonkeys.
the class EzyBroadcastAppsEventImplTest method test.
@Test
public void test() {
EzyEvent event2 = new EzySimpleServerInitializingEvent();
EzyZoneContext zoneContext = mock(EzyZoneContext.class);
List<EzyAppContext> appContexts = Lists.newArrayList(newAppContext("1", event2), newAppContext("2", event2), newAppContext("3", event2));
when(zoneContext.getAppContexts()).thenReturn(appContexts);
EzyZone zone = mock(EzyZone.class);
EzySimpleZoneSetting zoneSetting = new EzySimpleZoneSetting();
zoneSetting.setName("test");
when(zone.getSetting()).thenReturn(zoneSetting);
when(zoneContext.getZone()).thenReturn(zone);
EzyBroadcastAppsEventImpl cmd = new EzyBroadcastAppsEventImpl(zoneContext);
EzyEvent event = new EzySimpleServerInitializingEvent();
cmd.fire(EzyEventType.SERVER_INITIALIZING, event, true);
cmd.fire(EzyEventType.SERVER_INITIALIZING, event, false);
EzySimpleUser user = new EzySimpleUser();
user.setName("user1");
cmd.fire(EzyEventType.SERVER_INITIALIZING, event, user, true);
cmd.fire(EzyEventType.SERVER_INITIALIZING, event, "user1", true);
cmd.fire(EzyEventType.SERVER_INITIALIZING, event2, true);
}
use of com.tvd12.ezyfoxserver.client.event.EzyEvent in project ezyfox-server by youngmonkeys.
the class EzySimpleDataHandler method notifySessionRemoved.
protected void notifySessionRemoved(EzyConstant reason) {
if (zoneContext != null) {
EzyEvent event = newSessionRemovedEvent(reason);
notifyAppsSessionRemoved(event);
notifyPluginsSessionRemoved(event);
}
}
use of com.tvd12.ezyfoxserver.client.event.EzyEvent in project ezyfox-server by youngmonkeys.
the class EzySimpleAppUserDelegate method handleUserRemovedEvent.
protected void handleUserRemovedEvent(EzyUser user, EzyConstant reason) {
EzyEvent event = new EzySimpleUserRemovedEvent(user, reason);
appContext.handleEvent(EzyEventType.USER_REMOVED, event);
}
use of com.tvd12.ezyfoxserver.client.event.EzyEvent in project ezyfox-server-android-client by youngmonkeys.
the class EzySocketClient method reconnect.
public boolean reconnect() {
EzySocketStatus status = socketStatuses.last();
if (!isSocketReconnectable(status)) {
EzyLogger.warn("socket is not in a reconnectable status");
return false;
}
int maxReconnectCount = reconnectConfig.getMaxReconnectCount();
if (reconnectCount >= maxReconnectCount)
return false;
socketStatuses.push(EzySocketStatus.RECONNECTING);
int reconnectSleepTime = reconnectConfig.getReconnectPeriod();
connect0(reconnectSleepTime);
reconnectCount++;
EzyLogger.info("try reconnect to server: " + reconnectCount + ", wating time: " + reconnectSleepTime);
EzyEvent tryConnectEvent = new EzyTryConnectEvent(reconnectCount);
socketEventQueue.addEvent(tryConnectEvent);
return true;
}
Aggregations