|
@@ -5,6 +5,7 @@ import com.persagy.iottransfer.communication.mina.udp.server.UDPServerManager;
|
|
|
import com.persagy.iottransfer.config.CollectServerProperties;
|
|
|
import com.persagy.iottransfer.config.ControlServerProperties;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
/**
|
|
@@ -22,23 +23,29 @@ public class IotServer {
|
|
|
@Autowired
|
|
|
ControlServerProperties controlServerProperties;
|
|
|
|
|
|
- public void init() {
|
|
|
+ @Value("${iot.type.edge:false}")
|
|
|
+ private boolean edge;
|
|
|
|
|
|
- if (collectServerProperties.getTcp_enable()) {
|
|
|
- tcpCollectServerManager = new TCPServerManager(collectServerProperties.getTcp_bind_ip(), collectServerProperties.getTcp_bind_port(), "utf-8", collectServerProperties.getCompress(), collectServerProperties.getMax_size(), (byte) collectServerProperties.getSeparate_begin().charAt(0),
|
|
|
- (byte) collectServerProperties.getSeparate_end().charAt(0));
|
|
|
- tcpCollectServerManager.hasRemark(100);
|
|
|
- tcpCollectServerManager.Start();
|
|
|
- }
|
|
|
+ public void init() {
|
|
|
+ //直接连接边缘端侧iot-project的服务
|
|
|
+ if(edge){
|
|
|
+ if (collectServerProperties.getTcp_enable()) {
|
|
|
+ tcpCollectServerManager = new TCPServerManager(collectServerProperties.getTcp_bind_ip(), collectServerProperties.getTcp_bind_port(), "utf-8", collectServerProperties.getCompress(), collectServerProperties.getMax_size(), (byte) collectServerProperties.getSeparate_begin().charAt(0),
|
|
|
+ (byte) collectServerProperties.getSeparate_end().charAt(0));
|
|
|
+ tcpCollectServerManager.hasRemark(100);
|
|
|
+ tcpCollectServerManager.Start();
|
|
|
+ }
|
|
|
|
|
|
- if (controlServerProperties.getTcp_enable()) {
|
|
|
- tcpControlServerManager = new TCPServerManager(controlServerProperties.getTcp_bind_ip(), controlServerProperties.getTcp_bind_port(), "utf-8", controlServerProperties.getCompress(), controlServerProperties.getMax_size(), (byte) controlServerProperties.getSeparate_begin().charAt(0),
|
|
|
- (byte) controlServerProperties.getSeparate_end().charAt(0));
|
|
|
- tcpControlServerManager.hasRemark(100);
|
|
|
- tcpControlServerManager.Start();
|
|
|
+ if (controlServerProperties.getTcp_enable()) {
|
|
|
+ tcpControlServerManager = new TCPServerManager(controlServerProperties.getTcp_bind_ip(), controlServerProperties.getTcp_bind_port(), "utf-8", controlServerProperties.getCompress(), controlServerProperties.getMax_size(), (byte) controlServerProperties.getSeparate_begin().charAt(0),
|
|
|
+ (byte) controlServerProperties.getSeparate_end().charAt(0));
|
|
|
+ tcpControlServerManager.hasRemark(100);
|
|
|
+ tcpControlServerManager.Start();
|
|
|
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+
|
|
|
// public static UDPServerManager udpCollectServerManager = UDPServerManager.builder().build();
|
|
|
// public static UDPServerManager udpControlServerManager = UDPServerManager.builder().build();
|
|
|
// if (collectServerProperties.getUdp_enable()) {
|