Add timeout to network messages

This commit is contained in:
William committed 2022-08-24 22:30:00 +01:00
1 parent 98931c1900
commit d368befabd
2 files changed
+9 -7

No files matched your search

@@ -165,8 +165,10 @@ public class TeleportManager {
MessagePayload.withPosition(position),
Message.RelayType.MESSAGE,
plugin.getSettings().clusterId))
.orTimeout(3, TimeUnit.SECONDS)
.exceptionally(throwable -> null)
.thenApply(result -> {
if (result.payload.teleportResult == null) {
if (result == null || result.payload.teleportResult == null) {
return Optional.empty();
}
return Optional.of(result.payload.teleportResult);