Commit 40d031dc authored by AfirSraftGarrier's avatar AfirSraftGarrier

修改连接测试

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