it turns out i have the stupid (the WebServiceClient wasnt using threads.)
All checks were successful
/ Build BaseBand DSM & Broadway (push) Successful in 2m8s
All checks were successful
/ Build BaseBand DSM & Broadway (push) Successful in 2m8s
This commit is contained in:
parent
7ddf5f9349
commit
545296f2ce
1 changed files with 39 additions and 37 deletions
|
@ -20,50 +20,52 @@ public class WebServiceClient {
|
|||
public static void connect() {
|
||||
if(inputStream != null || outputStream != null)
|
||||
return;
|
||||
try {
|
||||
try(Socket client = new Socket("baseband.com.de", 40000)) {
|
||||
client.setSoTimeout(7000);
|
||||
client.getOutputStream().write(1); // client mode
|
||||
inputStream = new TypedInputStream(client.getInputStream());
|
||||
outputStream = new TypedOutputStream(client.getOutputStream());
|
||||
new Thread(() -> {
|
||||
try {
|
||||
try (Socket client = new Socket("baseband.com.de", 40000)) {
|
||||
client.setSoTimeout(7000);
|
||||
client.getOutputStream().write(1); // client mode
|
||||
inputStream = new TypedInputStream(client.getInputStream());
|
||||
outputStream = new TypedOutputStream(client.getOutputStream());
|
||||
|
||||
TCN init = new TCN();
|
||||
init.set("username", LoadHandler.data.getString("username"));
|
||||
init.set("type", "init");
|
||||
init.set("branch", LoadHandler.data.getString("branch"));
|
||||
outputStream.writeString(JSON.write(init));
|
||||
TCN init = new TCN();
|
||||
init.set("username", LoadHandler.data.getString("username"));
|
||||
init.set("type", "init");
|
||||
init.set("branch", LoadHandler.data.getString("branch"));
|
||||
outputStream.writeString(JSON.write(init));
|
||||
|
||||
int fails = 0;
|
||||
while (fails < 3) {
|
||||
try {
|
||||
String string = inputStream.readString();
|
||||
if(string.equals("SHUTDOWN."))
|
||||
BaseBand.shutdown();
|
||||
TCN packet = JSON.read(string);
|
||||
fails = 0;
|
||||
wasEverConnected = true;
|
||||
|
||||
handlePacket(packet);
|
||||
} catch (Exception e) {
|
||||
fails++;
|
||||
TCN keepAlive = new TCN();
|
||||
keepAlive.set("type", "c-keepalive");
|
||||
int fails = 0;
|
||||
while (fails < 3) {
|
||||
try {
|
||||
outputStream.writeString(JSON.write(keepAlive));
|
||||
} catch (Exception e1) {
|
||||
break;
|
||||
String string = inputStream.readString();
|
||||
if (string.equals("SHUTDOWN."))
|
||||
BaseBand.shutdown();
|
||||
TCN packet = JSON.read(string);
|
||||
fails = 0;
|
||||
wasEverConnected = true;
|
||||
|
||||
handlePacket(packet);
|
||||
} catch (Exception e) {
|
||||
fails++;
|
||||
TCN keepAlive = new TCN();
|
||||
keepAlive.set("type", "c-keepalive");
|
||||
try {
|
||||
outputStream.writeString(JSON.write(keepAlive));
|
||||
} catch (Exception e1) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
if (!wasEverConnected) {
|
||||
BaseBand.LOGGER.fatal(e);
|
||||
BaseBand.shutdown();
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
if(!wasEverConnected) {
|
||||
BaseBand.LOGGER.fatal(e);
|
||||
BaseBand.shutdown();
|
||||
}
|
||||
}
|
||||
inputStream = null;
|
||||
outputStream = null;
|
||||
inputStream = null;
|
||||
outputStream = null;
|
||||
}, "WebServiceClient").start();
|
||||
}
|
||||
|
||||
public static boolean outdated = false;
|
||||
|
|
Loading…
Add table
Reference in a new issue