|
@@ -1,29 +1,33 @@
|
|
|
package com.its.dsrc.xnettcp.dsrc.handler;
|
|
package com.its.dsrc.xnettcp.dsrc.handler;
|
|
|
|
|
|
|
|
import com.beanit.asn1dsrc.dsrc.C2CAuthenticatedMessage;
|
|
import com.beanit.asn1dsrc.dsrc.C2CAuthenticatedMessage;
|
|
|
|
|
+import com.beanit.asn1dsrc.enums.eAuthInfo;
|
|
|
import com.its.app.utils.NettyUtils;
|
|
import com.its.app.utils.NettyUtils;
|
|
|
import com.its.dsrc.config.RunningConfig;
|
|
import com.its.dsrc.config.RunningConfig;
|
|
|
import com.its.dsrc.entity.TbRseCtlr;
|
|
import com.its.dsrc.entity.TbRseCtlr;
|
|
|
import com.its.dsrc.global.AppRepository;
|
|
import com.its.dsrc.global.AppRepository;
|
|
|
|
|
+import com.its.dsrc.process.DbmsDataProcess;
|
|
|
|
|
+import com.its.dsrc.xnettcp.dsrc.process.response.InitiateResponse;
|
|
|
import com.its.dsrc.xnettcp.dsrc.process.response.LoginResponse;
|
|
import com.its.dsrc.xnettcp.dsrc.process.response.LoginResponse;
|
|
|
-import io.netty.channel.ChannelHandler;
|
|
|
|
|
|
|
+import com.its.dsrc.xnettcp.dsrc.process.service.LoginDeviceService;
|
|
|
import io.netty.channel.ChannelHandlerContext;
|
|
import io.netty.channel.ChannelHandlerContext;
|
|
|
import io.netty.channel.ChannelInboundHandlerAdapter;
|
|
import io.netty.channel.ChannelInboundHandlerAdapter;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.slf4j.MDC;
|
|
import org.slf4j.MDC;
|
|
|
-import org.springframework.stereotype.Component;
|
|
|
|
|
|
|
|
|
|
import java.util.concurrent.TimeUnit;
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
|
|
@Slf4j
|
|
@Slf4j
|
|
|
@RequiredArgsConstructor
|
|
@RequiredArgsConstructor
|
|
|
-@Component
|
|
|
|
|
-@ChannelHandler.Sharable
|
|
|
|
|
|
|
+//@Component
|
|
|
|
|
+//@ChannelHandler.Sharable
|
|
|
public class DsrcAsn1ServerLoginInboundHandler extends ChannelInboundHandlerAdapter {
|
|
public class DsrcAsn1ServerLoginInboundHandler extends ChannelInboundHandlerAdapter {
|
|
|
|
|
|
|
|
private final RunningConfig config;
|
|
private final RunningConfig config;
|
|
|
private final DsrcAsn1ServerPacketInboundHandler dsrcAsn1ServerPacketInboundHandler;
|
|
private final DsrcAsn1ServerPacketInboundHandler dsrcAsn1ServerPacketInboundHandler;
|
|
|
|
|
+ private final DbmsDataProcess dbmsDataProcess;
|
|
|
|
|
+ private final RunningConfig runningConfig;
|
|
|
|
|
|
|
|
// public DsrcAsn1ServerLoginInboundHandler() {
|
|
// public DsrcAsn1ServerLoginInboundHandler() {
|
|
|
// super();
|
|
// super();
|
|
@@ -64,12 +68,27 @@ public class DsrcAsn1ServerLoginInboundHandler extends ChannelInboundHandlerAdap
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ int allIdleTimeSec = 300;
|
|
|
C2CAuthenticatedMessage c2c = (C2CAuthenticatedMessage)msg;
|
|
C2CAuthenticatedMessage c2c = (C2CAuthenticatedMessage)msg;
|
|
|
- LoginResponse response = new LoginResponse(obj, ctx, c2c);
|
|
|
|
|
- if (!response.response()) {
|
|
|
|
|
- log.error("DsrcAsn1ServerLoginInboundHandler.-----------channelRead: {}. login failed. will be closed.", ipAddress);
|
|
|
|
|
- DsrcAsn1ServerIdleStateConnectionHandler.disconnectChannel(ctx.channel());
|
|
|
|
|
|
|
+ eAuthInfo cmd = eAuthInfo.getByValue(c2c.getDatexAuthenticationInfoText().value[0]);
|
|
|
|
|
+ if (cmd == eAuthInfo.AI_Initiate) {
|
|
|
|
|
+ InitiateResponse response = new InitiateResponse(obj, ctx, c2c);
|
|
|
|
|
+ if (!response.response(this.runningConfig)) {
|
|
|
|
|
+ log.error("DsrcAsn1ServerLoginInboundHandler.-----------channelRead: {}. AI_Initiate failed. will be closed.", ipAddress);
|
|
|
|
|
+ DsrcAsn1ServerIdleStateConnectionHandler.disconnectChannel(ctx.channel());
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ LoginDeviceService.getInstance().requestLogin(obj, ctx.channel(), this.runningConfig);
|
|
|
|
|
+ } else if (cmd == eAuthInfo.AI_Login) {
|
|
|
|
|
+ LoginResponse response = new LoginResponse(obj, ctx, c2c);
|
|
|
|
|
+ if (!response.response(this.runningConfig)) {
|
|
|
|
|
+ log.error("DsrcAsn1ServerLoginInboundHandler.-----------channelRead: {}. AI_Login failed. will be closed.", ipAddress);
|
|
|
|
|
+ DsrcAsn1ServerIdleStateConnectionHandler.disconnectChannel(ctx.channel());
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
return;
|
|
return;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ log.warn("DsrcAsn1ServerLoginInboundHandler: {}", cmd);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 로그인이 성공하면
|
|
// 로그인이 성공하면
|
|
@@ -78,7 +97,7 @@ public class DsrcAsn1ServerLoginInboundHandler extends ChannelInboundHandlerAdap
|
|
|
// 로그인 이전 네트워크 IDLE 체크 핸들러 삭제
|
|
// 로그인 이전 네트워크 IDLE 체크 핸들러 삭제
|
|
|
// 로그인 처리 핸들러 삭제
|
|
// 로그인 처리 핸들러 삭제
|
|
|
// 로그인 패킷 처리 핸들러 삭제
|
|
// 로그인 패킷 처리 핸들러 삭제
|
|
|
- int allIdleTimeSec = obj.getLogin().getDatexLoginHeartbeatDurationMaxQty().value.intValue()+5;
|
|
|
|
|
|
|
+ //int allIdleTimeSec = obj.getLogin().getDatexLoginHeartbeatDurationMaxQty().value.intValue()+5;
|
|
|
log.info("DsrcAsn1ServerLoginInboundHandler.-----------channelRead: {}, allIdleTimeSec: {} sec.", ipAddress, allIdleTimeSec);
|
|
log.info("DsrcAsn1ServerLoginInboundHandler.-----------channelRead: {}, allIdleTimeSec: {} sec.", ipAddress, allIdleTimeSec);
|
|
|
DsrcAsn1ServerIdleStatePacketHandler dsrcAsn1ServerIdleStatePacketHandler = new DsrcAsn1ServerIdleStatePacketHandler(
|
|
DsrcAsn1ServerIdleStatePacketHandler dsrcAsn1ServerIdleStatePacketHandler = new DsrcAsn1ServerIdleStatePacketHandler(
|
|
|
0,
|
|
0,
|
|
@@ -87,7 +106,7 @@ public class DsrcAsn1ServerLoginInboundHandler extends ChannelInboundHandlerAdap
|
|
|
TimeUnit.SECONDS
|
|
TimeUnit.SECONDS
|
|
|
);
|
|
);
|
|
|
ctx.channel().pipeline().addAfter("dsrcAsn1ServerConnectionIdleStateHandler","dsrcAsn1ServerIdleStateHandler", dsrcAsn1ServerIdleStatePacketHandler); // packet idle handler add
|
|
ctx.channel().pipeline().addAfter("dsrcAsn1ServerConnectionIdleStateHandler","dsrcAsn1ServerIdleStateHandler", dsrcAsn1ServerIdleStatePacketHandler); // packet idle handler add
|
|
|
- ctx.channel().pipeline().addAfter("dsrcAsn1ServerLoginInboundHandler","DsrcAsn1ServerPacketInboundHandler", this.dsrcAsn1ServerPacketInboundHandler); // packet distribute handler add
|
|
|
|
|
|
|
+ ctx.channel().pipeline().addAfter("dsrcAsn1ServerLoginInboundHandler","dsrcAsn1ServerPacketInboundHandler", this.dsrcAsn1ServerPacketInboundHandler); // packet distribute handler add
|
|
|
ctx.channel().pipeline().remove("dsrcAsn1ServerConnectionIdleStateHandler"); // login idle handler remove
|
|
ctx.channel().pipeline().remove("dsrcAsn1ServerConnectionIdleStateHandler"); // login idle handler remove
|
|
|
ctx.channel().pipeline().remove("dsrcAsn1ServerConnectionHandler"); // connection handler remove
|
|
ctx.channel().pipeline().remove("dsrcAsn1ServerConnectionHandler"); // connection handler remove
|
|
|
ctx.channel().pipeline().remove(this); // login handler remove
|
|
ctx.channel().pipeline().remove(this); // login handler remove
|