mirror of
https://github.com/tiennm99/zfoo.git
synced 2026-08-20 22:24:27 +00:00
perf[net]: 简化代码
This commit is contained in:
@@ -13,7 +13,6 @@
|
||||
|
||||
package com.zfoo.net.core.csharp;
|
||||
|
||||
import com.zfoo.net.NetContext;
|
||||
import com.zfoo.net.core.tcp.TcpServer;
|
||||
import com.zfoo.net.session.SessionUtils;
|
||||
import com.zfoo.util.ThreadUtils;
|
||||
@@ -36,8 +35,8 @@ public class ServerTest {
|
||||
SessionUtils.printSessionInfo();
|
||||
// startClient1();
|
||||
|
||||
var server0 = new TcpServer(HostAndPort.valueOf(NetContext.getConfigManager().getLocalConfig().getHostConfig().getAddressMap().get("server0")));
|
||||
server0.start();
|
||||
var server = new TcpServer(HostAndPort.valueOf("127.0.0.1:9000"));
|
||||
server.start();
|
||||
ThreadUtils.sleep(Long.MAX_VALUE);
|
||||
}
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ public class GatewayTest {
|
||||
public void startGateway() {
|
||||
var context = new ClassPathXmlApplicationContext("gateway/gateway_consistent_session_config.xml");
|
||||
SessionUtils.printSessionInfo();
|
||||
var gatewayServer = new GatewayServer(HostAndPort.valueOf(NetContext.getConfigManager().getLocalConfig().getHostConfig().getAddressMap().get("server0")), null);
|
||||
var gatewayServer = new GatewayServer(HostAndPort.valueOf("127.0.0.1:9000"), null);
|
||||
gatewayServer.start();
|
||||
ThreadUtils.sleep(Long.MAX_VALUE);
|
||||
}
|
||||
@@ -77,7 +77,7 @@ public class GatewayTest {
|
||||
var context = new ClassPathXmlApplicationContext("gateway/gateway_client_config.xml");
|
||||
SessionUtils.printSessionInfo();
|
||||
|
||||
var client = new TcpClient(HostAndPort.valueOf(NetContext.getConfigManager().getLocalConfig().getHostConfig().getAddressMap().get("server0")));
|
||||
var client = new TcpClient(HostAndPort.valueOf("127.0.0.1:9000"));
|
||||
var session = client.start();
|
||||
|
||||
var executorSize = Runtime.getRuntime().availableProcessors() * 2;
|
||||
|
||||
@@ -32,7 +32,7 @@ public class UdpClientTest {
|
||||
@Test
|
||||
public void startClientTest() {
|
||||
var context = new ClassPathXmlApplicationContext("config.xml");
|
||||
var hostAndPort = HostAndPort.valueOf(NetContext.getConfigManager().getLocalConfig().getHostConfig().getAddressMap().get("server0"));
|
||||
var hostAndPort = HostAndPort.valueOf("127.0.0.1:9000");
|
||||
var client = new UdpClient(hostAndPort);
|
||||
|
||||
var session = client.start();
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
|
||||
package com.zfoo.net.core.udp.server;
|
||||
|
||||
import com.zfoo.net.NetContext;
|
||||
import com.zfoo.net.core.udp.UdpServer;
|
||||
import com.zfoo.util.ThreadUtils;
|
||||
import com.zfoo.util.net.HostAndPort;
|
||||
@@ -30,7 +29,7 @@ public class UdpServerTest {
|
||||
@Test
|
||||
public void startServerTest() {
|
||||
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("config.xml");
|
||||
var server = new UdpServer(HostAndPort.valueOf(NetContext.getConfigManager().getLocalConfig().getHostConfig().getAddressMap().get("server0")));
|
||||
var server = new UdpServer(HostAndPort.valueOf("127.0.0.1:9000"));
|
||||
server.start();
|
||||
ThreadUtils.sleep(Long.MAX_VALUE);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user