Search in sources :

Example 1 with EzyConnectionSuccessHandler

use of com.tvd12.ezyfoxserver.client.handler.EzyConnectionSuccessHandler 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 EzyConnectionSuccessHandler

use of com.tvd12.ezyfoxserver.client.handler.EzyConnectionSuccessHandler 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 EzyConnectionSuccessHandler

use of com.tvd12.ezyfoxserver.client.handler.EzyConnectionSuccessHandler in project ezyfox-server-example by tvd12.

the class SimpleChatClient method setup.

protected EzyClient setup() {
    EzyClientConfig clientConfig = EzyClientConfig.builder().zoneName(ZONE_NAME).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("chat/sendMessage", new ChatSendMessageResponseHandler());
    appSetup.addDataHandler("greet", new ChatGreetResponseHandler());
    appSetup.addDataHandler("hello", new ChatHelloResponseHandler());
    return client;
}
Also used : EzyAppSetup(com.tvd12.ezyfoxserver.client.setup.EzyAppSetup) EzyClientConfig(com.tvd12.ezyfoxserver.client.config.EzyClientConfig) EzyClient(com.tvd12.ezyfoxserver.client.EzyClient) EzyConnectionFailureHandler(com.tvd12.ezyfoxserver.client.handler.EzyConnectionFailureHandler) EzyUTClient(com.tvd12.ezyfoxserver.client.EzyUTClient) EzySetup(com.tvd12.ezyfoxserver.client.setup.EzySetup) EzyConnectionSuccessHandler(com.tvd12.ezyfoxserver.client.handler.EzyConnectionSuccessHandler) EzyClients(com.tvd12.ezyfoxserver.client.EzyClients)

Example 4 with EzyConnectionSuccessHandler

use of com.tvd12.ezyfoxserver.client.handler.EzyConnectionSuccessHandler in project ezyfox-server-android-client by youngmonkeys.

the class EzySimpleHandlerManager method newEventHandlers.

private EzyEventHandlers newEventHandlers() {
    EzyEventHandlers handlers = new EzyEventHandlers(client, pingSchedule);
    handlers.addHandler(EzyEventType.CONNECTION_SUCCESS, new EzyConnectionSuccessHandler());
    handlers.addHandler(EzyEventType.CONNECTION_FAILURE, new EzyConnectionFailureHandler());
    handlers.addHandler(EzyEventType.DISCONNECTION, new EzyDisconnectionHandler());
    return handlers;
}
Also used : EzyEventHandlers(com.tvd12.ezyfoxserver.client.handler.EzyEventHandlers) EzyDisconnectionHandler(com.tvd12.ezyfoxserver.client.handler.EzyDisconnectionHandler) EzyConnectionFailureHandler(com.tvd12.ezyfoxserver.client.handler.EzyConnectionFailureHandler) EzyConnectionSuccessHandler(com.tvd12.ezyfoxserver.client.handler.EzyConnectionSuccessHandler)

Aggregations

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 EzyAppSetup (com.tvd12.ezyfoxserver.client.setup.EzyAppSetup)3 EzySetup (com.tvd12.ezyfoxserver.client.setup.EzySetup)3 EzyData (com.tvd12.ezyfox.entity.EzyData)2 EzyApp (com.tvd12.ezyfoxserver.client.entity.EzyApp)2 EzyConnectionFailureHandler (com.tvd12.ezyfoxserver.client.handler.EzyConnectionFailureHandler)2 EzyConnectionSuccessHandler (com.tvd12.ezyfoxserver.client.handler.EzyConnectionSuccessHandler)2 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 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 EzyDisconnectionHandler (com.tvd12.ezyfoxserver.client.handler.EzyDisconnectionHandler)1 EzyEventHandlers (com.tvd12.ezyfoxserver.client.handler.EzyEventHandlers)1 EzyAppAccessRequest (com.tvd12.ezyfoxserver.client.request.EzyAppAccessRequest)1