Search in sources :

Example 1 with EzySettingsBuilder

use of com.tvd12.ezyfoxserver.setting.EzySettingsBuilder in project ezyfox-server-example by tvd12.

the class PushMessageServerStartup method main.

public static void main(String[] args) throws Exception {
    EzyPluginSettingBuilder pluginSettingBuilder = new EzyPluginSettingBuilder().name(PLUGIN_NAME).addListenEvent(EzyEventType.USER_LOGIN).entryLoader(PluginEntryLoader.class);
    EzyAppSettingBuilder appSettingBuilder = new EzyAppSettingBuilder().name(APP_NAME).entryLoader(AppEntryLoader.class);
    EzyZoneSettingBuilder zoneSettingBuilder = new EzyZoneSettingBuilder().name(ZONE_NAME).application(appSettingBuilder.build()).plugin(pluginSettingBuilder.build());
    EzySimpleSettings settings = new EzySettingsBuilder().zone(zoneSettingBuilder.build()).build();
    EzyEmbeddedServer server = EzyEmbeddedServer.builder().settings(settings).build();
    server.start();
}
Also used : EzyEmbeddedServer(com.tvd12.ezyfoxserver.embedded.EzyEmbeddedServer)

Example 2 with EzySettingsBuilder

use of com.tvd12.ezyfoxserver.setting.EzySettingsBuilder in project ezyfox-server-example by tvd12.

the class SimpleChatStartup method main.

public static void main(String[] args) throws Exception {
    EzyPluginSettingBuilder pluginSettingBuilder = new EzyPluginSettingBuilder().name("simple-chat").addListenEvent(EzyEventType.USER_LOGIN).entryLoader(DecoratedPluginEntryLoader.class);
    EzyAppSettingBuilder appSettingBuilder = new EzyAppSettingBuilder().name("simple-chat").entryLoader(DecoratedAppEntryLoader.class);
    EzyZoneSettingBuilder zoneSettingBuilder = new EzyZoneSettingBuilder().name("example").application(appSettingBuilder.build()).plugin(pluginSettingBuilder.build());
    EzySimpleSettings settings = new EzySettingsBuilder().zone(zoneSettingBuilder.build()).build();
    EzyEmbeddedServer server = EzyEmbeddedServer.builder().settings(settings).build();
    server.start();
}
Also used : EzyPluginSettingBuilder(com.tvd12.ezyfoxserver.setting.EzyPluginSettingBuilder) EzyZoneSettingBuilder(com.tvd12.ezyfoxserver.setting.EzyZoneSettingBuilder) EzyAppSettingBuilder(com.tvd12.ezyfoxserver.setting.EzyAppSettingBuilder) EzySettingsBuilder(com.tvd12.ezyfoxserver.setting.EzySettingsBuilder) EzyEmbeddedServer(com.tvd12.ezyfoxserver.embedded.EzyEmbeddedServer) EzySimpleSettings(com.tvd12.ezyfoxserver.setting.EzySimpleSettings)

Example 3 with EzySettingsBuilder

use of com.tvd12.ezyfoxserver.setting.EzySettingsBuilder in project ezyfox-server-example by tvd12.

the class ServerStartup method main.

public static void main(String[] args) throws Exception {
    EzyPluginSettingBuilder pluginSettingBuilder = new EzyPluginSettingBuilder().name(PLUGIN_NAME).addListenEvent(EzyEventType.USER_LOGIN).entryLoader(PluginEntryLoader.class);
    EzyZoneSettingBuilder zoneSettingBuilder = new EzyZoneSettingBuilder().name(ZONE_NAME).plugin(pluginSettingBuilder.build());
    EzySimpleSettings settings = new EzySettingsBuilder().zone(zoneSettingBuilder.build()).build();
    EzyEmbeddedServer server = EzyEmbeddedServer.builder().settings(settings).build();
    server.start();
}
Also used : EzyPluginSettingBuilder(com.tvd12.ezyfoxserver.setting.EzyPluginSettingBuilder) EzyZoneSettingBuilder(com.tvd12.ezyfoxserver.setting.EzyZoneSettingBuilder) EzySettingsBuilder(com.tvd12.ezyfoxserver.setting.EzySettingsBuilder) EzyEmbeddedServer(com.tvd12.ezyfoxserver.embedded.EzyEmbeddedServer) EzySimpleSettings(com.tvd12.ezyfoxserver.setting.EzySimpleSettings)

Example 4 with EzySettingsBuilder

use of com.tvd12.ezyfoxserver.setting.EzySettingsBuilder in project ezyfox-server by youngmonkeys.

the class EzySettingsBuilderTest method test.

@Test
public void test() {
    EzySimpleStreamingSetting streamingSetting = new EzySimpleStreamingSetting();
    EzySimpleHttpSetting httpSetting = new EzySimpleHttpSetting();
    EzySimpleSocketSetting socketSetting = new EzySocketSettingBuilder().active(true).address("1.1.1.1").codecCreator(TestCodecCreator.class).maxRequestSize(1024).port(12345).tcpNoDelay(true).writerThreadPoolSize(3).build();
    EzySimpleUdpSetting udpSetting = new EzyUdpSettingBuilder().active(true).address("2.2.2.2").channelPoolSize(3).codecCreator(TestCodecCreator.class).handlerThreadPoolSize(3).maxRequestSize(2048).port(23456).build();
    EzySimpleSslConfigSetting sslConfigSetting = new EzySimpleSslConfigSetting();
    EzySimpleWebSocketSetting webSocketSetting = new EzyWebSocketSettingBuilder().active(true).address("1.1.1.1").codecCreator(TestCodecCreator.class).maxFrameSize(1024).port(12345).sslActive(true).sslConfig(sslConfigSetting).sslPort(23456).writerThreadPoolSize(3).build();
    EzySimpleAdminsSetting adminsSetting = new EzySimpleAdminsSetting();
    EzySimpleAdminSetting adminSetting = new EzyAdminSettingBuilder().accessToken("123").username("admin").password("123456").build();
    EzySimpleLoggerSetting loggerSetting = new EzySimpleLoggerSetting();
    EzySimpleThreadPoolSizeSetting threadPoolSizeSetting = new EzyThreadPoolSizeSettingBuilder().socketDataReceiver(1).extensionRequestHandler(2).socketDisconnectionHandler(3).socketUserRemovalHandler(4).statistics(5).streamHandler(6).systemRequestHandler(7).build();
    EzySimpleMaxRequestPerSecond maxRequestPerSecond = new EzyMaxRequestPerSecondBuilder().value(15).action(EzyMaxRequestPerSecondAction.DROP_REQUEST).build();
    EzySimpleSessionManagementSetting sessionManagementSetting = new EzySessionManagementSettingBuilder().sessionMaxIdleTimeInSecond(100).sessionMaxRequestPerSecond(maxRequestPerSecond).sessionMaxWaitingTimeInSecond(200).build();
    EzySimpleEventControllersSetting eventControllersSetting = new EzySimpleEventControllersSetting();
    EzySimpleZonesSetting zonesSetting = new EzySimpleZonesSetting();
    EzySimpleZoneSetting zoneSetting = new EzyZoneSettingBuilder().name("test").build();
    EzySimpleSettings settings = new EzySettingsBuilder().debug(true).nodeName("test").maxSessions(100).socket(socketSetting).udp(udpSetting).streaming(streamingSetting).http(httpSetting).websocket(webSocketSetting).admins(adminsSetting).admin(adminSetting).logger(loggerSetting).threadPoolSize(threadPoolSizeSetting).sessionManagement(sessionManagementSetting).eventControllers(eventControllersSetting).zones(zonesSetting).zone(zoneSetting).addEventController(EzyEventType.SERVER_INITIALIZING, HelloServerInitializingReadyController.class).build();
    assertTrue(settings.isDebug());
    assertEquals(settings.getNodeName(), "test");
    assertEquals(settings.getMaxSessions(), 100);
    assertEquals(settings.getStreaming(), streamingSetting);
    assertEquals(settings.getHttp(), httpSetting);
    socketSetting = settings.getSocket();
    assertTrue(socketSetting.isActive());
    assertEquals(socketSetting.getAddress(), "1.1.1.1");
    assertEquals(socketSetting.getCodecCreator(), TestCodecCreator.class.getName());
    assertEquals(socketSetting.getMaxRequestSize(), 1024);
    assertEquals(socketSetting.getPort(), 12345);
    assertTrue(socketSetting.isTcpNoDelay());
    assertEquals(socketSetting.getWriterThreadPoolSize(), 3);
    udpSetting = settings.getUdp();
    assertTrue(udpSetting.isActive());
    assertEquals(udpSetting.getAddress(), "2.2.2.2");
    assertEquals(udpSetting.getCodecCreator(), TestCodecCreator.class.getName());
    assertEquals(udpSetting.getMaxRequestSize(), 2048);
    assertEquals(udpSetting.getPort(), 23456);
    assertEquals(udpSetting.getChannelPoolSize(), 3);
    assertEquals(udpSetting.getHandlerThreadPoolSize(), 3);
    webSocketSetting = settings.getWebsocket();
    assertTrue(webSocketSetting.isActive());
    assertEquals(webSocketSetting.getAddress(), "1.1.1.1");
    assertEquals(webSocketSetting.getCodecCreator(), TestCodecCreator.class.getName());
    assertEquals(webSocketSetting.getMaxFrameSize(), 1024);
    assertEquals(webSocketSetting.getPort(), 12345);
    assertTrue(webSocketSetting.isSslActive());
    assertEquals(webSocketSetting.getSslConfig(), sslConfigSetting);
    assertEquals(webSocketSetting.getSslPort(), 23456);
    assertEquals(webSocketSetting.getWriterThreadPoolSize(), 3);
    assertEquals(settings.getAdmins(), adminsSetting);
    adminSetting = (EzySimpleAdminSetting) settings.getAdmins().getAdminByName("admin");
    assertEquals(adminSetting.getAccessToken(), "123");
    assertEquals(adminSetting.getUsername(), "admin");
    assertEquals(adminSetting.getPassword(), "123456");
    assertEquals(settings.getLogger(), loggerSetting);
    threadPoolSizeSetting = settings.getThreadPoolSize();
    assertEquals(threadPoolSizeSetting.getSocketDataReceiver(), 1);
    assertEquals(threadPoolSizeSetting.getExtensionRequestHandler(), 2);
    assertEquals(threadPoolSizeSetting.getSocketDisconnectionHandler(), 3);
    assertEquals(threadPoolSizeSetting.getSocketUserRemovalHandler(), 4);
    assertEquals(threadPoolSizeSetting.getStatistics(), 5);
    assertEquals(threadPoolSizeSetting.getStreamHandler(), 6);
    assertEquals(threadPoolSizeSetting.getSystemRequestHandler(), 7);
    sessionManagementSetting = settings.getSessionManagement();
    assertEquals(sessionManagementSetting.getSessionMaxIdleTimeInSecond(), 100);
    assertEquals(sessionManagementSetting.getSessionMaxRequestPerSecond(), maxRequestPerSecond);
    assertEquals(maxRequestPerSecond.getValue(), 15);
    assertEquals(maxRequestPerSecond.getAction(), EzyMaxRequestPerSecondAction.DROP_REQUEST);
    assertEquals(settings.getEventControllers(), eventControllersSetting);
    assertEquals(settings.getZones().getSize(), 1);
    assertEquals(zonesSetting.getZoneByName("test"), zoneSetting);
}
Also used : EzySimpleMaxRequestPerSecond(com.tvd12.ezyfoxserver.setting.EzySimpleSessionManagementSetting.EzySimpleMaxRequestPerSecond) EzyMaxRequestPerSecondBuilder(com.tvd12.ezyfoxserver.setting.EzySessionManagementSettingBuilder.EzyMaxRequestPerSecondBuilder) Test(org.testng.annotations.Test)

Example 5 with EzySettingsBuilder

use of com.tvd12.ezyfoxserver.setting.EzySettingsBuilder in project ezyfox-server by youngmonkeys.

the class EzyEmbeddedServerTest method test.

@Test
public void test() throws Exception {
    EzyPluginSettingBuilder pluginSettingBuilder = new EzyPluginSettingBuilder().name("test").entryLoader(TestPluginEntryLoader.class);
    EzyAppSettingBuilder appSettingBuilder = new EzyAppSettingBuilder().name("test").entryLoader(TestAppEntryLoader.class);
    EzyZoneSettingBuilder zoneSettingBuilder = new EzyZoneSettingBuilder().name("test").application(appSettingBuilder.build()).plugin(pluginSettingBuilder.build());
    EzySimpleUdpSetting udpSetting = new EzyUdpSettingBuilder().active(true).build();
    EzySimpleSettings settings = new EzySettingsBuilder().zone(zoneSettingBuilder.build()).udp(udpSetting).build();
    EzyEmbeddedServer server = EzyEmbeddedServer.builder().settings(settings).config(EzySimpleConfig.defaultConfig()).configFile("test-config/config.properties").build();
    EzyServerContext serverContext = server.start();
    Asserts.assertEquals(serverContext.getServer().getSettings(), settings);
    Thread.sleep(2000);
    server.stop();
}
Also used : EzyEmbeddedServer(com.tvd12.ezyfoxserver.embedded.EzyEmbeddedServer) EzyServerContext(com.tvd12.ezyfoxserver.context.EzyServerContext) Test(org.testng.annotations.Test)

Aggregations

EzyEmbeddedServer (com.tvd12.ezyfoxserver.embedded.EzyEmbeddedServer)9 Test (org.testng.annotations.Test)4 EzyPluginSettingBuilder (com.tvd12.ezyfoxserver.setting.EzyPluginSettingBuilder)2 EzyMaxRequestPerSecondBuilder (com.tvd12.ezyfoxserver.setting.EzySessionManagementSettingBuilder.EzyMaxRequestPerSecondBuilder)2 EzySettingsBuilder (com.tvd12.ezyfoxserver.setting.EzySettingsBuilder)2 EzySimpleMaxRequestPerSecond (com.tvd12.ezyfoxserver.setting.EzySimpleSessionManagementSetting.EzySimpleMaxRequestPerSecond)2 EzySimpleSettings (com.tvd12.ezyfoxserver.setting.EzySimpleSettings)2 EzyZoneSettingBuilder (com.tvd12.ezyfoxserver.setting.EzyZoneSettingBuilder)2 MsgPackCodecCreator (com.tvd12.ezyfox.codec.MsgPackCodecCreator)1 EzyServerContext (com.tvd12.ezyfoxserver.context.EzyServerContext)1 EzyAppSettingBuilder (com.tvd12.ezyfoxserver.setting.EzyAppSettingBuilder)1