From 2296a7fb15eb831778b07f08710a1e6e72bf9766 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=81=E6=98=BE=E4=BC=98?= <237809796@qq.com> Date: Thu, 23 Jun 2022 19:45:11 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=EF=BC=9Azhub=20=E9=AA=8C?= =?UTF-8?q?=E6=9D=83=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/com/zdemo/zhub/ZHubClient.java | 8 +++++++- test/HelloService.java | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/com/zdemo/zhub/ZHubClient.java b/src/com/zdemo/zhub/ZHubClient.java index 8b44c93..511cabe 100644 --- a/src/com/zdemo/zhub/ZHubClient.java +++ b/src/com/zdemo/zhub/ZHubClient.java @@ -34,6 +34,7 @@ public class ZHubClient extends AbstractConsumer implements IConsumer, IProducer private String addr = "127.0.0.1:1216"; //private String password = ""; private String groupid = ""; + private String auth = ""; private OutputStream writer; private BufferedReader reader; @@ -54,10 +55,11 @@ public class ZHubClient extends AbstractConsumer implements IConsumer, IProducer private boolean isMain = false;*/ private static final Map mainHub = new HashMap<>(); // 127.0.0.1:1216 - ZHubClient - public ZHubClient(String addr, String groupid, String appname) { + public ZHubClient(String addr, String groupid, String appname, String auth) { this.addr = addr; this.groupid = groupid; this.APP_NAME = appname; + this.auth = auth; init(null); } @@ -168,7 +170,10 @@ public class ZHubClient extends AbstractConsumer implements IConsumer, IProducer String topic = reader.readLine(); // name timerQueue.add(timerMap.get(topic)); + continue; } + + logger.finest(readLine); } catch (IOException e) { if (e instanceof SocketException) { initSocket(Integer.MAX_VALUE); @@ -345,6 +350,7 @@ public class ZHubClient extends AbstractConsumer implements IConsumer, IProducer if (groupid == null || groupid.isEmpty()) { throw new RuntimeException("ZHubClient groupid can not is empty"); } + send("auth", auth); send("groupid " + groupid); StringBuffer buf = new StringBuffer("subscribe lock"); diff --git a/test/HelloService.java b/test/HelloService.java index efc1e40..2e4dbcc 100644 --- a/test/HelloService.java +++ b/test/HelloService.java @@ -13,7 +13,7 @@ public class HelloService { @Before public void init() { - zhub = new ZHubClient("127.0.0.1:1216", "g-dev", "DEV-LOCAL"); + zhub = new ZHubClient("127.0.0.1:1216", "g-dev", "DEV-LOCAL", "zchd@123456"); //zhub.init(Map.of("host", "47.111.150.118", "port", "6066", "groupid", "g-dev", "appname", "DEV-LOCAL")); // Function, RpcResult> fun