Skip to content

Commit 73e171d

Browse files
committed
try fix
1 parent d5d14e5 commit 73e171d

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

src/main/java/cn/ussshenzhou/channel/subspace/client/SubspaceConnection.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,13 +213,15 @@ protected void initChannel(SocketChannel ch) {
213213
if (!activelyDisconnect) {
214214
LogUtils.getLogger().warn("Disconnected from subspace. Reconnecting in 10s...");
215215
reconnectFuture = group.schedule(() -> connect(packet), 10, TimeUnit.SECONDS);
216+
channel = null;
216217
}
217218
});
218219
send(new HandshakePacket());
219220
MicrophoneHud.setStatus(MicrophoneHud.Status.STANDBY);
220221
} else {
221222
LogUtils.getLogger().error("Failed to connect to subspace server. Try again in 10s...");
222223
reconnectFuture = group.schedule(() -> connect(packet), 10, TimeUnit.SECONDS);
224+
channel = null;
223225
}
224226
});
225227
}

src/main/java/cn/ussshenzhou/channel/subspace/server/SubspaceConnection.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,19 +75,21 @@ protected void initChannel(SocketChannel ch) {
7575
if (!activelyDisconnect) {
7676
LogUtils.getLogger().warn("Disconnected from subspace. Reconnecting in 10s...");
7777
group.schedule(SubspaceConnection::connect, 10, TimeUnit.SECONDS);
78+
channel = null;
7879
}
7980
});
8081
send(new InitPacket());
8182
LogUtils.getLogger().info("Subspace server connected.");
8283
group.schedule(() -> {
83-
LockSupport.parkNanos(TimeUnit.MILLISECONDS.toNanos(1000));
84+
LockSupport.parkNanos(TimeUnit.SECONDS.toNanos(3000));
8485
if (channel.isActive() && ServerLifecycleHooks.getCurrentServer() != null) {
8586
ServerLifecycleHooks.getCurrentServer().getPlayerList().getPlayers().forEach(SubspaceConnection::newPlayer);
8687
}
8788
}, 1, TimeUnit.SECONDS);
8889
} else {
8990
LogUtils.getLogger().error("Failed to connect to subspace server. Try again in 10s...");
9091
group.schedule(SubspaceConnection::connect, 10, TimeUnit.SECONDS);
92+
channel = null;
9193
}
9294
});
9395
}

0 commit comments

Comments
 (0)