diff options
author | Keuin <[email protected]> | 2022-07-31 16:28:16 +0800 |
---|---|---|
committer | Keuin <[email protected]> | 2022-07-31 16:28:16 +0800 |
commit | b3afabec920d32e5e8d86aead400e039cce43c87 (patch) | |
tree | bb75ad4fac99aff8b82169bd73961c828517ac9f /src/main/java/com/keuin/psmb4j/BaseClient.java | |
parent | 5a9378342236a8439934b0f4703c0c3cc0e084e3 (diff) |
Implement HTTP message API (legacy function from Bungeecross.MicroApi).
Diffstat (limited to 'src/main/java/com/keuin/psmb4j/BaseClient.java')
-rw-r--r-- | src/main/java/com/keuin/psmb4j/BaseClient.java | 25 |
1 files changed, 13 insertions, 12 deletions
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() { |