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);
}
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;
}
Aggregations