Search in sources :

Example 1 with EzyAppSetup

use of com.tvd12.ezyfoxserver.client.setup.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;
}
Also used : EzyAppSetup(com.tvd12.ezyfoxserver.client.setup.EzyAppSetup) EzyClientConfig(com.tvd12.ezyfoxserver.client.config.EzyClientConfig) EzyClient(com.tvd12.ezyfoxserver.client.EzyClient) EzyData(com.tvd12.ezyfox.entity.EzyData) EzyUTClient(com.tvd12.ezyfoxserver.client.EzyUTClient) EzyApp(com.tvd12.ezyfoxserver.client.entity.EzyApp) EzySetup(com.tvd12.ezyfoxserver.client.setup.EzySetup) EzyClients(com.tvd12.ezyfoxserver.client.EzyClients)

Example 2 with EzyAppSetup

use of com.tvd12.ezyfoxserver.client.setup.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;
}
Also used : EzyApp(com.tvd12.ezyfoxserver.client.entity.EzyApp) com.tvd12.ezyfoxserver.client.handler(com.tvd12.ezyfoxserver.client.handler) EzyData(com.tvd12.ezyfox.entity.EzyData) EzyArray(com.tvd12.ezyfox.entity.EzyArray) EzyClients(com.tvd12.ezyfoxserver.client.EzyClients) EzyRequest(com.tvd12.ezyfoxserver.client.request.EzyRequest) EzyAppAccessRequest(com.tvd12.ezyfoxserver.client.request.EzyAppAccessRequest) EzyStrings(com.tvd12.ezyfox.io.EzyStrings) HashMap(java.util.HashMap) EzySetup(com.tvd12.ezyfoxserver.client.setup.EzySetup) EzyUTClient(com.tvd12.ezyfoxserver.client.EzyUTClient) EzyLoginRequest(com.tvd12.ezyfoxserver.client.request.EzyLoginRequest) PostRequest(com.tvd12.ezyhttp.client.request.PostRequest) EzyClient(com.tvd12.ezyfoxserver.client.EzyClient) EzyClientConfig(com.tvd12.ezyfoxserver.client.config.EzyClientConfig) EzyAppSetup(com.tvd12.ezyfoxserver.client.setup.EzyAppSetup) EzyEventType(com.tvd12.ezyfoxserver.client.event.EzyEventType) EzyMainEventsLoop(com.tvd12.ezyfoxserver.client.socket.EzyMainEventsLoop) EzyObject(com.tvd12.ezyfox.entity.EzyObject) Map(java.util.Map) EzyEntityObjects(com.tvd12.ezyfox.util.EzyEntityObjects) EzyCommand(com.tvd12.ezyfoxserver.client.constant.EzyCommand) HttpClient(com.tvd12.ezyhttp.client.HttpClient) EzyAppSetup(com.tvd12.ezyfoxserver.client.setup.EzyAppSetup) EzyClientConfig(com.tvd12.ezyfoxserver.client.config.EzyClientConfig) EzyClient(com.tvd12.ezyfoxserver.client.EzyClient) EzyData(com.tvd12.ezyfox.entity.EzyData) EzyUTClient(com.tvd12.ezyfoxserver.client.EzyUTClient) EzySetup(com.tvd12.ezyfoxserver.client.setup.EzySetup) EzyClients(com.tvd12.ezyfoxserver.client.EzyClients)

Example 3 with EzyAppSetup

use of com.tvd12.ezyfoxserver.client.setup.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);
}
Also used : ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) EzyAppSetup(com.tvd12.ezyfoxserver.command.EzyAppSetup) EzyZoneContext(com.tvd12.ezyfoxserver.context.EzyZoneContext) EzyBeanContext(com.tvd12.ezyfox.bean.EzyBeanContext) EzyServerContext(com.tvd12.ezyfoxserver.context.EzyServerContext) EzyAppContext(com.tvd12.ezyfoxserver.context.EzyAppContext) EzyAppSetting(com.tvd12.ezyfoxserver.setting.EzyAppSetting) EzyApplication(com.tvd12.ezyfoxserver.EzyApplication) EzyAppUserManager(com.tvd12.ezyfoxserver.wrapper.EzyAppUserManager) EzySingleton(com.tvd12.ezyfox.bean.annotation.EzySingleton) Test(org.testng.annotations.Test)

Example 4 with EzyAppSetup

use of com.tvd12.ezyfoxserver.client.setup.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;
}
Also used : EzyAppDataHandlers(com.tvd12.ezyfoxserver.client.handler.EzyAppDataHandlers)

Example 5 with EzyAppSetup

use of com.tvd12.ezyfoxserver.client.setup.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);
    });
}
Also used : UdpHandshakeHandler(com.tvd12.ezyfoxserver.stresstest.handler.UdpHandshakeHandler) HandshakeHandler(com.tvd12.ezyfoxserver.stresstest.handler.HandshakeHandler) EzyAppSetup(com.tvd12.ezyfoxserver.client.setup.EzyAppSetup) UdpHandshakeHandler(com.tvd12.ezyfoxserver.stresstest.handler.UdpHandshakeHandler) LoginSuccessHandler(com.tvd12.ezyfoxserver.stresstest.handler.LoginSuccessHandler) EzySetup(com.tvd12.ezyfoxserver.client.setup.EzySetup) AccessAppHandler(com.tvd12.ezyfoxserver.stresstest.handler.AccessAppHandler)

Aggregations

EzyAppSetup (com.tvd12.ezyfoxserver.client.setup.EzyAppSetup)4 EzySetup (com.tvd12.ezyfoxserver.client.setup.EzySetup)4 EzyClient (com.tvd12.ezyfoxserver.client.EzyClient)3 EzyClients (com.tvd12.ezyfoxserver.client.EzyClients)3 EzyUTClient (com.tvd12.ezyfoxserver.client.EzyUTClient)3 EzyClientConfig (com.tvd12.ezyfoxserver.client.config.EzyClientConfig)3 EzyData (com.tvd12.ezyfox.entity.EzyData)2 EzyApp (com.tvd12.ezyfoxserver.client.entity.EzyApp)2 EzyAppSetup (com.tvd12.ezyfoxserver.command.EzyAppSetup)2 EzyBeanContext (com.tvd12.ezyfox.bean.EzyBeanContext)1 EzySingleton (com.tvd12.ezyfox.bean.annotation.EzySingleton)1 EzyArray (com.tvd12.ezyfox.entity.EzyArray)1 EzyObject (com.tvd12.ezyfox.entity.EzyObject)1 EzyStrings (com.tvd12.ezyfox.io.EzyStrings)1 EzyEntityObjects (com.tvd12.ezyfox.util.EzyEntityObjects)1 EzyApplication (com.tvd12.ezyfoxserver.EzyApplication)1 EzyAppRequestController (com.tvd12.ezyfoxserver.app.EzyAppRequestController)1 EzyCommand (com.tvd12.ezyfoxserver.client.constant.EzyCommand)1 EzyEventType (com.tvd12.ezyfoxserver.client.event.EzyEventType)1 com.tvd12.ezyfoxserver.client.handler (com.tvd12.ezyfoxserver.client.handler)1