use of com.tvd12.ezyfoxserver.command.EzyAppSetup in project ezyfox-server-example by tvd12.
the class HelloWorldClient method setup.
protected EzyClient setup() {
EzyClientConfig clientConfig = EzyClientConfig.builder().zoneName(ZONE_NAME).enableSSL().enableDebug().build();
EzyClients clients = EzyClients.getInstance();
EzyClient client = new EzyUTClient(clientConfig);
clients.addClient(client);
EzySetup setup = client.setup();
setup.addEventHandler(EzyEventType.CONNECTION_SUCCESS, new EzyConnectionSuccessHandler());
setup.addEventHandler(EzyEventType.CONNECTION_FAILURE, new EzyConnectionFailureHandler());
setup.addDataHandler(EzyCommand.HANDSHAKE, new ExHandshakeEventHandler());
setup.addDataHandler(EzyCommand.LOGIN, new ExLoginSuccessHandler());
setup.addDataHandler(EzyCommand.APP_ACCESS, new ExAccessAppHandler());
EzyAppSetup appSetup = setup.setupApp(APP_NAME);
appSetup.addDataHandler("greet", new ChatGreetResponseHandler());
appSetup.addDataHandler("secureChat", new SecureChatResponseHandler());
appSetup.addDataHandler("chatAll", new EzyAppDataHandler<EzyData>() {
@Override
public void handle(EzyApp app, EzyData data) {
System.out.println("chatAll: " + data);
}
});
appSetup.addDataHandler("chat1", new EzyAppDataHandler<EzyData>() {
@Override
public void handle(EzyApp app, EzyData data) {
System.out.println("chat1: " + data);
}
});
appSetup.addDataHandler("chatToMe", new EzyAppDataHandler<EzyData>() {
@Override
public void handle(EzyApp app, EzyData data) {
System.out.println("chatToMe: " + data);
}
});
appSetup.addDataHandler("err", new EzyAppDataHandler<EzyData>() {
@Override
public void handle(EzyApp app, EzyData data) {
System.out.println("error: " + data);
}
});
return client;
}
use of com.tvd12.ezyfoxserver.command.EzyAppSetup in project ezyfox-server-example by tvd12.
the class HelloWorldClientUdp method setup.
protected EzyClient setup() {
EzyClientConfig clientConfig = EzyClientConfig.builder().zoneName(ZONE_NAME).enableSSL().enableDebug().build();
EzyClients clients = EzyClients.getInstance();
EzyClient client = new EzyUTClient(clientConfig);
clients.addClient(client);
EzySetup setup = client.setup();
setup.addEventHandler(EzyEventType.CONNECTION_SUCCESS, new EzyConnectionSuccessHandler());
setup.addEventHandler(EzyEventType.CONNECTION_FAILURE, new EzyConnectionFailureHandler());
setup.addDataHandler(EzyCommand.HANDSHAKE, new ExHandshakeEventHandler());
setup.addDataHandler(EzyCommand.LOGIN, new ExLoginSuccessHandler());
setup.addDataHandler(EzyCommand.UDP_HANDSHAKE, new ExHandshakeSuccessHandler());
setup.addDataHandler(EzyCommand.APP_ACCESS, new ExAccessAppHandler());
EzyAppSetup appSetup = setup.setupApp(APP_NAME);
appSetup.addDataHandler("greet", new ChatGreetResponseHandler());
appSetup.addDataHandler("udpGreet", (EzyAppDataHandler<EzyData>) (app, data) -> System.out.println("udpGreet: " + data));
appSetup.addDataHandler("secureChat", new SecureChatResponseHandler());
appSetup.addDataHandler("chatAll", (EzyAppDataHandler<EzyData>) (app, data) -> System.out.println("chatAll: " + data));
appSetup.addDataHandler("chat1", (EzyAppDataHandler<EzyData>) (app, data) -> System.out.println("chat1: " + data));
appSetup.addDataHandler("chatToMe", (EzyAppDataHandler<EzyData>) (app, data) -> System.out.println("chatToMe: " + data));
appSetup.addDataHandler("err", (EzyAppDataHandler<EzyData>) (app, data) -> System.out.println("error: " + data));
return client;
}
use of com.tvd12.ezyfoxserver.command.EzyAppSetup in project ezyfox-server by youngmonkeys.
the class EzySimpleAppEntryTest method scanPackages.
@Test
public void scanPackages() {
// given
EzyAppContext appContext = mock(EzyAppContext.class);
ScheduledExecutorService executorService = mock(ScheduledExecutorService.class);
EzyZoneContext zoneContext = mock(EzyZoneContext.class);
EzyServerContext serverContext = mock(EzyServerContext.class);
EzyApplication application = mock(EzyApplication.class);
EzyAppUserManager appUserManager = mock(EzyAppUserManager.class);
EzyAppSetup appSetup = mock(EzyAppSetup.class);
EzyAppSetting appSetting = mock(EzyAppSetting.class);
when(application.getSetting()).thenReturn(appSetting);
InternalAppEntry sut = new InternalAppEntry();
// when
when(appContext.get(ScheduledExecutorService.class)).thenReturn(executorService);
when(appContext.getParent()).thenReturn(zoneContext);
when(zoneContext.getParent()).thenReturn(serverContext);
when(appContext.getApp()).thenReturn(application);
when(application.getUserManager()).thenReturn(appUserManager);
when(appContext.get(EzyAppSetup.class)).thenReturn(appSetup);
sut.config(appContext);
// 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);
}
use of com.tvd12.ezyfoxserver.command.EzyAppSetup in project ezyfox-server-android-client by youngmonkeys.
the class EzySimpleSetup method setupApp.
@Override
public EzyAppSetup setupApp(String appName) {
EzyAppSetup appSetup = appSetups.get(appName);
if (appSetup == null) {
EzyAppDataHandlers dataHandlers = handlerManager.getAppDataHandlers(appName);
appSetup = new EzySimpleAppSetup(dataHandlers, this);
appSetups.put(appName, appSetup);
}
return appSetup;
}
use of com.tvd12.ezyfoxserver.command.EzyAppSetup in project ezyfox-server-example by tvd12.
the class SocketClientSetup method setup.
public void setup(EzyClient client, boolean useUdp) {
int count = counter.incrementAndGet();
EzySetup setup = client.setup();
setup.addDataHandler(EzyCommand.HANDSHAKE, new HandshakeHandler(count));
setup.addDataHandler(EzyCommand.LOGIN, new LoginSuccessHandler(useUdp));
setup.addDataHandler(EzyCommand.UDP_HANDSHAKE, new UdpHandshakeHandler());
setup.addDataHandler(EzyCommand.APP_ACCESS, new AccessAppHandler(useUdp, messageCount, executorService));
EzyAppSetup appSetup = setup.setupApp("hello-world");
appSetup.addDataHandler("broadcastMessage", (app, data) -> {
// String message = ((EzyObject)data).get("message", String.class);
// System.out.println("tcp > server response: " + message);
});
appSetup.addDataHandler("udpBroadcastMessage", (app, data) -> {
// String message = ((EzyObject)data).get("message", String.class);
// System.out.println("udp > server response: " + message);
});
}
Aggregations