|
@@ -3,7 +3,6 @@ package com.sig.ggits.server.tcp.initializer;
|
|
|
import com.sig.app.common.xnet.NettyUtils;
|
|
|
import com.sig.ggits.server.common.SpringUtils;
|
|
|
import com.sig.ggits.server.config.ApplicationConfig;
|
|
|
-import com.sig.ggits.server.dto.RegionCenter;
|
|
|
import com.sig.ggits.server.service.AppRepositoryService;
|
|
|
import com.sig.ggits.server.tcp.codec.SigSendByteBufMessageEncoder;
|
|
|
import com.sig.ggits.server.tcp.handler.SigCommServerInboundMessageHandler;
|
|
@@ -12,8 +11,6 @@ import io.netty.channel.Channel;
|
|
|
import io.netty.channel.ChannelInitializer;
|
|
|
import io.netty.channel.ChannelPipeline;
|
|
|
import io.netty.handler.codec.LengthFieldBasedFrameDecoder;
|
|
|
-import io.netty.handler.logging.LogLevel;
|
|
|
-import io.netty.handler.logging.LoggingHandler;
|
|
|
import io.netty.handler.timeout.IdleStateHandler;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
@@ -35,29 +32,37 @@ public class SigCommServerInitializer extends ChannelInitializer<Channel> {
|
|
|
@Override
|
|
|
protected void initChannel(Channel channel) throws Exception {
|
|
|
String ipAddress = NettyUtils.getRemoteIpAddress(channel);
|
|
|
- RegionCenter center = this.appRepository.getIpAddrMap(ipAddress);
|
|
|
- if (center == null) {
|
|
|
- log.error("SigCommServerInitializer.----initChannel: {}, Unknown ip address. will be closed.", ipAddress);
|
|
|
- channel.disconnect();
|
|
|
- channel.close();
|
|
|
- return;
|
|
|
- }
|
|
|
- if (center.getNetState().getChannel() != null) {
|
|
|
- log.warn("SigCommServerInitializer.----initChannel: {}, {}, Already Connected. Old Connection will be closed.", ipAddress, center.getRegionCd());
|
|
|
- // 이벤트 핸들러 에서 중복 처리 되지 않도록 속성 값을 제거
|
|
|
- channel.attr(AppRepositoryService.SIG_REGION_ATTRIBUTE_KEY).set(null);
|
|
|
- center.getNetState().disConnect();
|
|
|
+ log.info("SigCommServerInitializer.----initChannel: Connected From : {}", ipAddress);
|
|
|
+// if (!ipAddress.equals("localhost")) {
|
|
|
+// log.error("SigCommServerInitializer.----initChannel: {}, Unknown ip address. will be closed.", ipAddress);
|
|
|
+// channel.disconnect();
|
|
|
+// channel.close();
|
|
|
+// return;
|
|
|
+// }
|
|
|
|
|
|
- channel.disconnect();
|
|
|
- channel.close();
|
|
|
- }
|
|
|
-
|
|
|
- center.getNetState().connect(channel);
|
|
|
- channel.attr(AppRepositoryService.SIG_REGION_ATTRIBUTE_KEY).set(center);
|
|
|
+// RegionCenter center = this.appRepository.getIpAddrMap(ipAddress);
|
|
|
+// if (center == null) {
|
|
|
+// log.error("SigCommServerInitializer.----initChannel: {}, Unknown ip address. will be closed.", ipAddress);
|
|
|
+// channel.disconnect();
|
|
|
+// channel.close();
|
|
|
+// return;
|
|
|
+// }
|
|
|
+// if (center.getNetState().getChannel() != null) {
|
|
|
+// log.warn("SigCommServerInitializer.----initChannel: {}, {}, Already Connected. Old Connection will be closed.", ipAddress, center.getRegionCd());
|
|
|
+// // 이벤트 핸들러 에서 중복 처리 되지 않도록 속성 값을 제거
|
|
|
+// channel.attr(AppRepositoryService.SIG_REGION_ATTRIBUTE_KEY).set(null);
|
|
|
+// center.getNetState().disConnect();
|
|
|
+//
|
|
|
+// channel.disconnect();
|
|
|
+// channel.close();
|
|
|
+// }
|
|
|
+//
|
|
|
+// center.getNetState().connect(channel);
|
|
|
+// channel.attr(AppRepositoryService.SIG_REGION_ATTRIBUTE_KEY).set(center);
|
|
|
|
|
|
IdleStateHandler idleStateHandler = new IdleStateHandler(this.config.getReaderIdleTimeSeconds(), 0, 0);
|
|
|
ChannelPipeline pipeline = channel.pipeline();
|
|
|
- pipeline.addLast(new LoggingHandler(LogLevel.INFO));
|
|
|
+ //pipeline.addLast(new LoggingHandler(LogLevel.INFO));
|
|
|
pipeline.addLast("idleStateHandler", idleStateHandler);
|
|
|
pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(
|
|
|
SigProtocolConst.SIG_MAX_PACKET,
|