Anh ơi, em muốn hỏi thêm về response từ Server về client. Phía dưới là đoạn main trong TCPSocket của em, em mong muốn là nó chỉ login 1 lần và trả về kết quả chỉ 1 lần thôi. Hiện tại em đang bị nó trả về liên tục nên không thể biết được là số response / user là bao nhiêu và cũng như là số request / giây, số response / giây, số response / số request.
java
public static void main(String[] args) {
DefaultClientConfig clientConfig = new DefaultClientConfig();
SocketClientSetup setup = new SocketClientSetup("tcp-socket");
EzyClients clients = EzyClients.getInstance();
EzyEventLoopGroup eventLoopGroup = new EzyEventLoopGroup(1);
EventLoopGroup nettyEventLoopGroup = new EzyNettyEventLoopGroup(1);
LocalDateTime Starttime = java.time.LocalDateTime.now();
LocalDateTime Endtime = null;
long differentInSeconds = 0;
new Thread(() -> {
int clientCount = 10;
for (int i = 0; i < clientCount; i++) {
EzyTcpClient client = new EzyTcpClient(
clientConfig.get(i),
eventLoopGroup,
nettyEventLoopGroup
);
try {
Thread.sleep(25);
} catch (Exception e) {
e.printStackTrace();
}
setup.setup(client, false);
clients.addClient(client);
client.connect("127.0.0.1", 3005);
}
})
.start();
Endtime = java.time.LocalDateTime.now();
differentInSeconds = Duration.between(Starttime, Endtime).getSeconds();
System.out.println("===================StartTime==================");
System.out.println(Starttime);
System.out.println("===================EndTime==================");
System.out.println(Endtime);
System.out.println("===================Duration==================");
System.out.println(differentInSeconds);
EzyMainEventsLoop mainEventsLoop = new EzyMainEventsLoop();
mainEventsLoop.start(1);
}