Skip to content

Commit 4f0aff2

Browse files
committed
去掉了断线重连逻辑,若需要断线后识别出用户本身并重连,应在客户端的config文件中拿到用户名确定ctx与服务端联动
1 parent ca2ead7 commit 4f0aff2

File tree

1 file changed

+0
-32
lines changed

1 file changed

+0
-32
lines changed

run/src/main/java/org/wowtools/hppt/run/ss/common/ServerSessionService.java

-32
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import org.wowtools.hppt.common.server.LoginClientService;
55
import org.wowtools.hppt.common.server.ServerSessionManager;
66
import org.wowtools.hppt.common.server.ServerTalker;
7-
import org.wowtools.hppt.common.util.BytesUtil;
87
import org.wowtools.hppt.common.util.GridAesCipherUtil;
98
import org.wowtools.hppt.run.ss.pojo.SsConfig;
109
import org.wowtools.hppt.run.ss.util.SsUtil;
@@ -27,7 +26,6 @@ private final class ClientCell {
2726
LoginClientService.Client client;
2827
volatile boolean running = true;
2928
volatile boolean actived = true;
30-
final String reConnectToken = UUID.randomUUID().toString();
3129

3230
CTX ctx;
3331
final LoginClientService.ClientActiveWatcher clientActiveWatcher = new LoginClientService.ClientActiveWatcher() {
@@ -133,36 +131,6 @@ public void receiveClientBytes(CTX ctx, byte[] bytes) {
133131
login = GridAesCipherUtil.encrypt(login);
134132
sendBytesToClient(ctx, login);
135133
break;
136-
case "reConnect":
137-
byte[] base64Bytes = BytesUtil.base642bytes(cmd[1]);
138-
ClientCell currentClientCell = null;
139-
for (Map.Entry<CTX, ClientCell> entry : ctxClientCellMap.entrySet()) {
140-
ClientCell clientCell1 = entry.getValue();
141-
try {
142-
byte[] decryptBytes = clientCell1.client.aesCipherUtil.descriptor.decrypt(base64Bytes);
143-
String[] codes = new String(decryptBytes, StandardCharsets.UTF_8).split(" ", 2);
144-
String reConnectCode = codes[0];
145-
if (!clientCell1.reConnectToken.equals(reConnectCode)) {
146-
log.info("重连token不匹配");
147-
continue;
148-
}
149-
long st = Long.valueOf(codes[1]);
150-
long now = System.currentTimeMillis();
151-
if (Math.abs(now - st) > 60000) {
152-
log.info("重连时差过大 st {} now {}", st, now);
153-
continue;
154-
}
155-
} catch (Exception e) {
156-
continue;
157-
}
158-
currentClientCell = clientCell1;
159-
break;
160-
}
161-
if (currentClientCell != null) {
162-
ctxClientCellMap.put(ctx, currentClientCell);
163-
log.info("客户端重连成功 {}", currentClientCell.client.clientId);
164-
}
165-
break;
166134
default:
167135
log.warn("未知命令 {} ", s);
168136
removeCtx(ctx);

0 commit comments

Comments
 (0)