use of com.tvd12.ezyfoxserver.context.EzyZoneContext in project ezyfox-server by youngmonkeys.
the class EzySimpleAppUserDelegate method responseUserRemoved.
protected void responseUserRemoved(EzyUser user, EzyConstant reason) {
EzyResponse response = newExitedAppResponse(reason);
EzyZoneContext zoneContext = appContext.getParent();
zoneContext.send(response, user, false);
}
use of com.tvd12.ezyfoxserver.context.EzyZoneContext in project ezyfox-server by youngmonkeys.
the class EzySimpleStreamingController method handle.
@Override
public void handle(EzyZoneContext ctx, EzyStreamingRequest request) {
EzyStreamingEvent event = new EzySimpleStreamingEvent(request.getUser(), request.getSession(), request.getBytes());
ctx.handleEvent(EzyEventType.STREAMING, event);
}
use of com.tvd12.ezyfoxserver.context.EzyZoneContext in project ezyfox-server by youngmonkeys.
the class BaseCoreTest method newServerContext.
protected EzyServerContext newServerContext() {
EzyServerContext serverContext = newServerContextBuilder().build();
for (EzyZoneContext zoneContext : serverContext.getZoneContexts()) {
((EzyInitable) zoneContext).init();
}
for (EzyAppContext appContext : serverContext.getAppContexts()) {
((EzyInitable) appContext).init();
}
EzySimpleServerContext ctx = (EzySimpleServerContext) serverContext;
EzySimpleServer server = (EzySimpleServer) ctx.getServer();
server.setResponseApi(mock(EzyResponseApi.class));
return ctx;
}
use of com.tvd12.ezyfoxserver.context.EzyZoneContext 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.context.EzyZoneContext in project ezyfox-server by youngmonkeys.
the class EzySimplePluginEntryTest method scanPackages.
@Test
public void scanPackages() {
// given
EzyPluginContext pluginContext = mock(EzyPluginContext.class);
ScheduledExecutorService executorService = mock(ScheduledExecutorService.class);
EzyZoneContext zoneContext = mock(EzyZoneContext.class);
EzyServerContext serverContext = mock(EzyServerContext.class);
EzyPluginSetup pluginSetup = mock(EzyPluginSetup.class);
EzyPlugin plugin = mock(EzyPlugin.class);
when(pluginContext.getPlugin()).thenReturn(plugin);
EzyPluginSetting pluginSetting = mock(EzyPluginSetting.class);
when(plugin.getSetting()).thenReturn(pluginSetting);
InternalPluginEntry sut = new InternalPluginEntry();
// when
when(pluginContext.get(ScheduledExecutorService.class)).thenReturn(executorService);
when(pluginContext.getParent()).thenReturn(zoneContext);
when(zoneContext.getParent()).thenReturn(serverContext);
when(pluginContext.get(EzyPluginSetup.class)).thenReturn(pluginSetup);
sut.config(pluginContext);
// then
EzyBeanContext beanContext = sut.beanContext;
MongoConfig mongoConfig = (MongoConfig) beanContext.getBean(MongoConfig.class);
Set<String> expectedPackages = Sets.newHashSet(EzySupportConstants.DEFAULT_PACKAGE_TO_SCAN, "com.tvd12.ezyfoxserver.support.v120.test.entry");
Asserts.assertEquals(expectedPackages, mongoConfig.packagesToScan);
Singleton singleton = (Singleton) beanContext.getBean(Singleton.class);
Asserts.assertNotNull(singleton);
}
Aggregations