Skip to content

Commit 201f478

Browse files
committed
修复一些idea给出的建议问题
1 parent 6bd1629 commit 201f478

File tree

3 files changed

+15
-9
lines changed

3 files changed

+15
-9
lines changed

run/src/main/java/org/wowtools/hppt/common/server/LoginClientService.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public List<SendAbleSessionBytes> fetchBytes(long maxReturnBodySize) {
105105
break;
106106
}
107107
bytesList.add(next);
108-
currentReturnBodySize += next.sessionBytes.getBytes().length;
108+
currentReturnBodySize += next.sessionBytes().getBytes().length;
109109
}
110110
}
111111
return merge(bytesList);
@@ -128,14 +128,14 @@ public List<SendAbleSessionBytes> fetchBytesBlocked(long maxReturnBodySize) {
128128
return merge(bytesList);
129129
} else {
130130
//根据maxReturnBodySize的限制取出队列中的数据返回
131-
long currentReturnBodySize = first.sessionBytes.getBytes().length;
131+
long currentReturnBodySize = first.sessionBytes().getBytes().length;
132132
while (currentReturnBodySize < maxReturnBodySize) {
133133
SendAbleSessionBytes next = sessionBytesQueue.poll();
134134
if (null == next) {
135135
break;
136136
}
137137
bytesList.add(next);
138-
currentReturnBodySize += next.sessionBytes.getBytes().length;
138+
currentReturnBodySize += next.sessionBytes().getBytes().length;
139139
}
140140
return merge(bytesList);
141141
}
@@ -150,9 +150,9 @@ private static final class MergeCell {
150150
private static List<SendAbleSessionBytes> merge(List<SendAbleSessionBytes> bytesList) {
151151
Map<Integer, MergeCell> bytesMap = new HashMap<>();
152152
for (SendAbleSessionBytes ssb : bytesList) {
153-
MergeCell mergeCell = bytesMap.computeIfAbsent(ssb.sessionBytes.getSessionId(), (r) -> new MergeCell());
154-
mergeCell.bytesList.add(ssb.sessionBytes.getBytes());
155-
mergeCell.callBacks.add(ssb.callBack);
153+
MergeCell mergeCell = bytesMap.computeIfAbsent(ssb.sessionBytes().getSessionId(), (r) -> new MergeCell());
154+
mergeCell.bytesList.add(ssb.sessionBytes().getBytes());
155+
mergeCell.callBacks.add(ssb.callBack());
156156
}
157157
List<SendAbleSessionBytes> res = new ArrayList<>(bytesMap.size());
158158
bytesMap.forEach((sessionId, mergeCell) -> {

run/src/main/java/org/wowtools/hppt/common/server/ServerTalker.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -130,13 +130,13 @@ public static void replyToClient(CommonConfig config, ServerSessionManager serve
130130
if (null != fetchBytes && !fetchBytes.isEmpty()) {
131131
if (DebugConfig.OpenSerialNumber) {
132132
for (SendAbleSessionBytes ssb : fetchBytes) {
133-
log.debug("生成向客户端回复的消息 <sessionBytes-SerialNumber {}", ssb.sessionBytes.getSerialNumber());
133+
log.debug("生成向客户端回复的消息 <sessionBytes-SerialNumber {}", ssb.sessionBytes().getSerialNumber());
134134
}
135135
}
136136

137137
sessionBytes = new ArrayList<>(fetchBytes.size());
138138
for (SendAbleSessionBytes ssb : fetchBytes) {
139-
SessionBytes fetchByte = ssb.sessionBytes;
139+
SessionBytes fetchByte = ssb.sessionBytes();
140140
sessionBytes.add(fetchByte);
141141
}
142142
empty = false;
@@ -167,7 +167,7 @@ public static void replyToClient(CommonConfig config, ServerSessionManager serve
167167

168168
if (null != fetchBytes) {
169169
for (SendAbleSessionBytes fetchByte : fetchBytes) {
170-
sendAbleSessionBytesResultQueue.add(new SendAbleSessionBytesResult(success, fetchByte.callBack));
170+
sendAbleSessionBytesResultQueue.add(new SendAbleSessionBytesResult(success, fetchByte.callBack()));
171171
}
172172
}
173173

run/src/main/java/org/wowtools/hppt/run/sc/common/PortReceiver.java

+6
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@ public PortReceiver(ScConfig config, ClientSessionService clientSessionService)
5656
}
5757
log.info("连接建立完成");
5858
Thread.startVirtualThread(() -> {
59+
//休眠一下等待clientSessionService初始化完成,解决native下启动时可能得空指针问题
60+
try {
61+
Thread.sleep(10);
62+
} catch (InterruptedException e) {
63+
throw new RuntimeException(e);
64+
}
5965
//建立连接后,获取时间戳
6066
clientSessionService.sendBytesToServer(GridAesCipherUtil.encrypt("dt".getBytes(StandardCharsets.UTF_8)));
6167
//等待时间戳返回

0 commit comments

Comments
 (0)