Search in sources :

Example 6 with EzyClients

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

the class WebSocketStresstest method main.

public static void main(String[] args) throws Exception {
    DefaultClientConfig clientConfig = new DefaultClientConfig();
    SocketClientSetup setup = new SocketClientSetup("websocket");
    EzyClients clients = EzyClients.getInstance();
    new Thread(() -> {
        int clientCount = 300;
        for (int i = 0; i < clientCount; i++) {
            EzyWsClient client = new EzyWsClient(clientConfig.get(i));
            try {
                Thread.sleep(50);
            } catch (Exception e) {
                e.printStackTrace();
            }
            setup.setup(client, false);
            clients.addClient(client);
            client.connect("ws://127.0.0.1:2208/ws");
        }
    }).start();
    EzyMainEventsLoop mainEventsLoop = new EzyMainEventsLoop();
    mainEventsLoop.start(5);
}
Also used : EzyWsClient(com.tvd12.ezyfoxserver.client.EzyWsClient) EzyClients(com.tvd12.ezyfoxserver.client.EzyClients) EzyMainEventsLoop(com.tvd12.ezyfoxserver.client.socket.EzyMainEventsLoop)

Example 7 with EzyClients

use of com.tvd12.ezyfoxserver.client.EzyClients 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)

Aggregations

EzyClients (com.tvd12.ezyfoxserver.client.EzyClients)7 EzyClient (com.tvd12.ezyfoxserver.client.EzyClient)4 EzyUTClient (com.tvd12.ezyfoxserver.client.EzyUTClient)4 EzyMainEventsLoop (com.tvd12.ezyfoxserver.client.socket.EzyMainEventsLoop)4 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 EzyTcpClient (com.tvd12.ezyfoxserver.client.EzyTcpClient)2 EzyApp (com.tvd12.ezyfoxserver.client.entity.EzyApp)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 EzyWsClient (com.tvd12.ezyfoxserver.client.EzyWsClient)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 EzyConnectionFailureHandler (com.tvd12.ezyfoxserver.client.handler.EzyConnectionFailureHandler)1 EzyConnectionSuccessHandler (com.tvd12.ezyfoxserver.client.handler.EzyConnectionSuccessHandler)1