SteamWar/FightSystem
Archiviert
13
1

Reduce blocking on spectatesystem-blackout

Signed-off-by: Lixfel <agga-games@gmx.de>
Dieser Commit ist enthalten in:
Lixfel 2020-10-15 10:52:06 +02:00
Ursprung ac1af7ffeb
Commit 66b6e5a6dd

Datei anzeigen

@ -22,9 +22,7 @@ package de.steamwar.fightsystem.record;
import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.Config;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import java.io.BufferedOutputStream; import java.io.*;
import java.io.DataOutputStream;
import java.io.IOException;
import java.net.Socket; import java.net.Socket;
import java.util.logging.Level; import java.util.logging.Level;
@ -32,11 +30,15 @@ public class SpectateConnection extends Recorder{
private Socket socket; private Socket socket;
private DataOutputStream outputStream; private DataOutputStream outputStream;
private PipedInputStream inputStream;
SpectateConnection(){ SpectateConnection(){
super(); super();
try { try {
this.socket = new Socket(Config.spectateIP, Config.spectatePort); 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())); this.outputStream = new DataOutputStream(new BufferedOutputStream(socket.getOutputStream()));
} catch (IOException e) { } catch (IOException e) {
Bukkit.getLogger().log(Level.SEVERE, "Could not init connection", e); Bukkit.getLogger().log(Level.SEVERE, "Could not init connection", e);