Commit 40d031dc authored by AfirSraftGarrier's avatar AfirSraftGarrier

修改连接测试

parent 9dbff062
...@@ -16,7 +16,6 @@ public class DeviceClientInactiveEventHandler { ...@@ -16,7 +16,6 @@ public class DeviceClientInactiveEventHandler {
EventPublisher eventPublisher; EventPublisher eventPublisher;
public DeviceClientInactiveEventHandler() { public DeviceClientInactiveEventHandler() {
} }
@EventListener @EventListener
...@@ -25,24 +24,21 @@ public class DeviceClientInactiveEventHandler { ...@@ -25,24 +24,21 @@ public class DeviceClientInactiveEventHandler {
SessionContext session = deviceManager.getSessionByChannelId(channelId); SessionContext session = deviceManager.getSessionByChannelId(channelId);
if (session == null) { if (session == null) {
log.debug("device client inactive undo ..."); log.info("device client inactive undo ...");
return; return;
} else { } else {
String appId = session.getAppId(); String sn = session.getSn();
// boolean result = deviceManager.removeSessionByChannelId(channelId); // boolean result = deviceManager.removeSessionByChannelId(channelId);
boolean result = deviceManager.changeSessionOffline(channelId); boolean result = deviceManager.changeSessionOffline(channelId);
if (result) { if (result) {
// TODO device client 离线需要强制中断该设备对应的forward client // device client 离线需要强制中断该设备对应的forward client
ForwardClientBeForcedOfflineEvent forwardClientBeForcedOfflineEvent = new ForwardClientBeForcedOfflineEvent(); ForwardClientBeForcedOfflineEvent forwardClientBeForcedOfflineEvent = new ForwardClientBeForcedOfflineEvent();
forwardClientBeForcedOfflineEvent.setSn(appId); forwardClientBeForcedOfflineEvent.setSn(sn);
eventPublisher.publishEvent(forwardClientBeForcedOfflineEvent); eventPublisher.publishEvent(forwardClientBeForcedOfflineEvent);
log.debug("device client inactive success ..."); log.info("device client inactive success ...");
} }
} }
} }
} }
......
...@@ -21,7 +21,7 @@ public class ForwardClientConnectEventHandler { ...@@ -21,7 +21,7 @@ public class ForwardClientConnectEventHandler {
@EventListener @EventListener
public void handlerEvent(ForwardClientConnectEvent event) { public void handlerEvent(ForwardClientConnectEvent event) {
String appId = event.getSn(); String sn = event.getSn();
String channelId = event.getChannelId(); String channelId = event.getChannelId();
SocketChannel channel = event.getChannel(); SocketChannel channel = event.getChannel();
...@@ -29,14 +29,14 @@ public class ForwardClientConnectEventHandler { ...@@ -29,14 +29,14 @@ public class ForwardClientConnectEventHandler {
SessionContext session = new SessionContext(); SessionContext session = new SessionContext();
// session.setRemoteIp(remoteIp); // session.setRemoteIp(remoteIp);
// session.setRemotePort(remotePort); // session.setRemotePort(remotePort);
session.setAppId(appId); session.setSn(sn);
// session.setAppKey(appKey); // session.setAppKey(appKey);
// session.setToken(token); // session.setToken(token);
session.setChannelId(channelId); session.setChannelId(channelId);
session.setClientChannel(channel); session.setClientChannel(channel);
forwardManager.putSession(appId, session); forwardManager.putSession(sn, session);
log.debug("forward client connect:" + event); log.debug("forward client connect:" + event);
} }
......
...@@ -31,14 +31,11 @@ public class ForwardClientRequestEventHandler { ...@@ -31,14 +31,11 @@ public class ForwardClientRequestEventHandler {
DeviceProtocol protocol = event.getProtocol(); DeviceProtocol protocol = event.getProtocol();
SessionContext deviceSessionContext = deviceManager.getSessionByChannelId(deviceChannelId); SessionContext deviceSessionContext = deviceManager.getSessionByChannelId(deviceChannelId);
String appId = deviceSessionContext.getAppId(); String sn = deviceSessionContext.getSn();
SessionContext forwardSessionContext = forwardManager.getSessionContextBySN(appId); SessionContext forwardSessionContext = forwardManager.getSessionContextBySN(sn);
log.debug("forward client request:" + appId + "," + forwardSessionContext); log.info("forward client request:" + sn + "," + forwardSessionContext);
SocketChannel clientChannel = forwardSessionContext.getClientChannel(); SocketChannel clientChannel = forwardSessionContext.getClientChannel();
clientChannel.writeAndFlush(protocol); clientChannel.writeAndFlush(protocol);
} }
} }
...@@ -2,7 +2,6 @@ package iot.sixiang.license.service; ...@@ -2,7 +2,6 @@ package iot.sixiang.license.service;
import iot.sixiang.license.model.ResResult; import iot.sixiang.license.model.ResResult;
import iot.sixiang.license.model.dto.GetTerminalDeviceTokenDTO; import iot.sixiang.license.model.dto.GetTerminalDeviceTokenDTO;
import iot.sixiang.license.model.vo.GetTerminalDeviceTokenVO;
public interface TerminalDeviceService { public interface TerminalDeviceService {
ResResult getToken(GetTerminalDeviceTokenDTO getTerminalDeviceTokenDTO); ResResult getToken(GetTerminalDeviceTokenDTO getTerminalDeviceTokenDTO);
......
...@@ -55,7 +55,7 @@ public class DeviceControllerTest { ...@@ -55,7 +55,7 @@ public class DeviceControllerTest {
int serverPort = 18889; int serverPort = 18889;
String appId = "ebsh71dp5t1ck948l5"; String appId = "ebsh71dp5t1ck948l5";
String sn = "ERE54S619LNYMPKVN9"; String sn = "ERE54S619LNYMPKVN9";
String snBind = "snabcd"; String snBind = "ZA2207G5NQ";
String appKey = "110801"; String appKey = "110801";
socket(serverIp, serverPort, appId, sn, snBind, appKey); socket(serverIp, serverPort, appId, sn, snBind, appKey);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment