From b3afabec920d32e5e8d86aead400e039cce43c87 Mon Sep 17 00:00:00 2001 From: Keuin Date: Sun, 31 Jul 2022 16:28:16 +0800 Subject: Implement HTTP message API (legacy function from Bungeecross.MicroApi). --- src/main/java/com/keuin/psmb4j/BaseClient.java | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'src/main/java/com/keuin/psmb4j') diff --git a/src/main/java/com/keuin/psmb4j/BaseClient.java b/src/main/java/com/keuin/psmb4j/BaseClient.java index 3c5cf08..0fd5274 100644 --- a/src/main/java/com/keuin/psmb4j/BaseClient.java +++ b/src/main/java/com/keuin/psmb4j/BaseClient.java @@ -39,6 +39,7 @@ public abstract class BaseClient implements AutoCloseable { * and should be called only once. * If an IO error occurred when doing some operation, * this client must be reconnected before next operations. + * * @throws IOException if a network error occurred */ public void connect() throws IOException { @@ -74,19 +75,19 @@ public abstract class BaseClient implements AutoCloseable { public void keepAlive() throws IOException { final var nop = new byte[]{'N', 'O', 'P'}; final var nil = new byte[]{'N', 'I', 'L'}; - synchronized (socketReadLock) { - synchronized (socketWriteLock) { - // lock the whole bidirectional communication - os.write(nop); - os.flush(); - // wait for a response NIL - var response = InputStreamUtils.readBytes(is, 3); - if (!Arrays.equals(response, nil)) { - throw new RuntimeException("illegal command from server: " + - new String(response, StandardCharsets.US_ASCII)); - } - } +// synchronized (socketReadLock) { + synchronized (socketWriteLock) { + // lock the whole bidirectional communication + os.write(nop); + os.flush(); +// // wait for a response NIL +// var response = InputStreamUtils.readBytes(is, 3); +// if (!Arrays.equals(response, nil)) { +// throw new RuntimeException("illegal command from server: " + +// new String(response, StandardCharsets.US_ASCII)); +// } } +// } } public void disconnect() { -- cgit v1.2.3