From 66b6e5a6ddb913680762376a6664c0ab9f2422ef Mon Sep 17 00:00:00 2001 From: Lixfel Date: Thu, 15 Oct 2020 10:52:06 +0200 Subject: [PATCH] Reduce blocking on spectatesystem-blackout Signed-off-by: Lixfel --- .../steamwar/fightsystem/record/SpectateConnection.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/record/SpectateConnection.java b/FightSystem_Main/src/de/steamwar/fightsystem/record/SpectateConnection.java index 298758e..2ccf537 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/record/SpectateConnection.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/record/SpectateConnection.java @@ -22,9 +22,7 @@ package de.steamwar.fightsystem.record; import de.steamwar.fightsystem.Config; import org.bukkit.Bukkit; -import java.io.BufferedOutputStream; -import java.io.DataOutputStream; -import java.io.IOException; +import java.io.*; import java.net.Socket; import java.util.logging.Level; @@ -32,11 +30,15 @@ public class SpectateConnection extends Recorder{ private Socket socket; private DataOutputStream outputStream; + private PipedInputStream inputStream; SpectateConnection(){ super(); try { this.socket = new Socket(Config.spectateIP, Config.spectatePort); + socket.setSoTimeout(1); // Wait a maximum of 1ms on a blocking operation (flush) + socket.setSoLinger(true, 1); // Wait a maximum of 1ms on close + socket.setTcpNoDelay(true); // Don't wait always on ack this.outputStream = new DataOutputStream(new BufferedOutputStream(socket.getOutputStream())); } catch (IOException e) { Bukkit.getLogger().log(Level.SEVERE, "Could not init connection", e);