From 12a58002c5f73e448fc1bcc8b3a86cd7df30d31d Mon Sep 17 00:00:00 2001 From: Acexy Date: Thu, 3 May 2018 14:53:20 +0800 Subject: [PATCH] 1.1.1 --- README.md | 6 +- .../wqq/core/request/aop/DoRequest.java | 8 +-- .../wqq/core/request/api/SendBuddyMsg2.java | 4 +- .../wqq/core/request/api/SendDiscuMsg2.java | 4 +- .../wqq/core/request/api/SendQunMsg2.java | 3 +- .../thankjava/wqq/extend/ActionListener.java | 6 +- .../thankjava/wqq/extend/NotifyListener.java | 6 ++ ...ssageHandler.java => MessageListener.java} | 62 +++++++++---------- .../thankjava/wqq/test/qq/TestSmartQQ.java | 2 +- 9 files changed, 51 insertions(+), 50 deletions(-) rename src/test/java/com/thankjava/wqq/test/qq/{MessageHandler.java => MessageListener.java} (91%) diff --git a/README.md b/README.md index d48449a..d1c775a 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,8 @@ 废弃主动登录接口,合并到初始化自动完成 闭环登录环节的相关异常,各个需要业务控制的回调均提供反馈调用 增加稳定性,新增应用健康状态监控,提供优化掉线自动重连机制 + 1.1.1 + 移除了历史版本登录测试方法和历史登录的相关支持代码 ``` --- @@ -53,7 +55,7 @@ - 1.1.0之前(后续会彻底废弃) ``` -参考com.thankjava.wqq.test.qq.TestSmartQQ & com.thankjava.wqq.test.qq.MessageHandler +参考com.thankjava.wqq.test.qq.TestSmartQQ & com.thankjava.wqq.test.qq.MessageListener ``` ```java package com.thankjava.wqq.test.qq; @@ -125,7 +127,7 @@ public class TestSmartQQ { ``` - 1.1.0之后新版 ``` -参考com.thankjava.wqq.test.qq.TestSmartQQNewVersion & com.thankjava.wqq.test.qq.MessageHandler +参考com.thankjava.wqq.test.qq.TestSmartQQNewVersion & com.thankjava.wqq.test.qq.MessageListener ``` ```java package com.thankjava.wqq.test.qq; diff --git a/src/main/java/com/thankjava/wqq/core/request/aop/DoRequest.java b/src/main/java/com/thankjava/wqq/core/request/aop/DoRequest.java index 2f3304e..554bbcc 100644 --- a/src/main/java/com/thankjava/wqq/core/request/aop/DoRequest.java +++ b/src/main/java/com/thankjava/wqq/core/request/aop/DoRequest.java @@ -37,15 +37,13 @@ public AopParam doRequest(AopParam aopParam) { if (listener != null) { // 如果传递了listener 则通过listener的方式回调返回 - ActionListener actionListener = new ActionListener(); try { - actionListener.setData(asyncHttpClient.syncRequestWithSession(asyncRequest)); + listener.onListener(new ActionListener((asyncHttpClient.syncRequestWithSession(asyncRequest)))); } catch (Throwable e) { logger.error("http request error", e); - actionListener.setData(null); + listener.onListener(new ActionListener()); } - listener.onListener(actionListener); - + } else { try { diff --git a/src/main/java/com/thankjava/wqq/core/request/api/SendBuddyMsg2.java b/src/main/java/com/thankjava/wqq/core/request/api/SendBuddyMsg2.java index 263e0e0..80c69b8 100644 --- a/src/main/java/com/thankjava/wqq/core/request/api/SendBuddyMsg2.java +++ b/src/main/java/com/thankjava/wqq/core/request/api/SendBuddyMsg2.java @@ -24,9 +24,7 @@ public SendBuddyMsg2(SendMsg sendMsg) { @Override public AsyncResponse doRequest(CallBackListener listener) { if(listener != null){ - ActionListener actionListener = new ActionListener(); - actionListener.setData(asyncHttpClient.syncRequestWithSession(buildRequestParams())); - listener.onListener(actionListener); + listener.onListener(new ActionListener(asyncHttpClient.syncRequestWithSession(buildRequestParams()))); return null; }else{ return asyncHttpClient.syncRequestWithSession(buildRequestParams()); diff --git a/src/main/java/com/thankjava/wqq/core/request/api/SendDiscuMsg2.java b/src/main/java/com/thankjava/wqq/core/request/api/SendDiscuMsg2.java index db38c6e..c39aabf 100644 --- a/src/main/java/com/thankjava/wqq/core/request/api/SendDiscuMsg2.java +++ b/src/main/java/com/thankjava/wqq/core/request/api/SendDiscuMsg2.java @@ -24,9 +24,7 @@ public SendDiscuMsg2(SendMsg sendMsg) { @Override public AsyncResponse doRequest(CallBackListener listener) { if(listener != null){ - ActionListener actionListener = new ActionListener(); - actionListener.setData(asyncHttpClient.syncRequestWithSession(buildRequestParams())); - listener.onListener(actionListener); + listener.onListener(new ActionListener(asyncHttpClient.syncRequestWithSession(buildRequestParams()))); return null; }else{ return asyncHttpClient.syncRequestWithSession(buildRequestParams()); diff --git a/src/main/java/com/thankjava/wqq/core/request/api/SendQunMsg2.java b/src/main/java/com/thankjava/wqq/core/request/api/SendQunMsg2.java index 21159f1..d62df47 100644 --- a/src/main/java/com/thankjava/wqq/core/request/api/SendQunMsg2.java +++ b/src/main/java/com/thankjava/wqq/core/request/api/SendQunMsg2.java @@ -24,8 +24,7 @@ public SendQunMsg2(SendMsg sendMsg) { @Override public AsyncResponse doRequest(CallBackListener listener) { if(listener != null){ - ActionListener actionListener = new ActionListener(); - actionListener.setData(asyncHttpClient.syncRequestWithSession(buildRequestParams())); + ActionListener actionListener = new ActionListener(asyncHttpClient.syncRequestWithSession(buildRequestParams())); listener.onListener(actionListener); return null; }else{ diff --git a/src/main/java/com/thankjava/wqq/extend/ActionListener.java b/src/main/java/com/thankjava/wqq/extend/ActionListener.java index 06a5dd2..d25f541 100644 --- a/src/main/java/com/thankjava/wqq/extend/ActionListener.java +++ b/src/main/java/com/thankjava/wqq/extend/ActionListener.java @@ -23,8 +23,8 @@ public Object getData() { return data; } - public void setData(Object data) { - this.data = data; - } +// public void setData(Object data) { +// this.data = data; +// } } diff --git a/src/main/java/com/thankjava/wqq/extend/NotifyListener.java b/src/main/java/com/thankjava/wqq/extend/NotifyListener.java index 3bc44c1..5e8c571 100644 --- a/src/main/java/com/thankjava/wqq/extend/NotifyListener.java +++ b/src/main/java/com/thankjava/wqq/extend/NotifyListener.java @@ -8,5 +8,11 @@ */ public interface NotifyListener { + + /** + * 消息通知处理定义 + * @param smartQQClient + * @param pollMsg + */ public void handler(SmartQQClient smartQQClient, PollMsg pollMsg); } diff --git a/src/test/java/com/thankjava/wqq/test/qq/MessageHandler.java b/src/test/java/com/thankjava/wqq/test/qq/MessageListener.java similarity index 91% rename from src/test/java/com/thankjava/wqq/test/qq/MessageHandler.java rename to src/test/java/com/thankjava/wqq/test/qq/MessageListener.java index 2dd729d..cb4bcaf 100644 --- a/src/test/java/com/thankjava/wqq/test/qq/MessageHandler.java +++ b/src/test/java/com/thankjava/wqq/test/qq/MessageListener.java @@ -1,31 +1,31 @@ -package com.thankjava.wqq.test.qq; - -import com.thankjava.wqq.SmartQQClient; -import com.thankjava.wqq.entity.msg.PollMsg; -import com.thankjava.wqq.entity.msg.SendMsg; -import com.thankjava.wqq.extend.NotifyListener; - -public class MessageHandler implements NotifyListener { - - @Override - public void handler(SmartQQClient smartQQClient, PollMsg pollMsg) { - switch (pollMsg.getMsgType()) { - case message: - smartQQClient.sendMsg(new SendMsg(pollMsg, "I Have Got Your Msg: `Friend`")); - break; - case group_message: - smartQQClient.sendMsg(new SendMsg(pollMsg, "I Have Got Your Msg: `Group`")); - break; - case discu_message: - smartQQClient.sendMsg(new SendMsg(pollMsg, "I Have Got Your Msg: `Discu`")); - break; - } - } - - // sendMsg 接口能通过pollMsg得到msg的类型,然后自动回复该类型的msg -// @Override -// public void handler(SmartQQClient smartQQClient, PollMsg pollMsg) { -// smartQQClient.sendMsg(new SendMsg(pollMsg, "I Have Got Your Msg")); -// } - -} +package com.thankjava.wqq.test.qq; + +import com.thankjava.wqq.SmartQQClient; +import com.thankjava.wqq.entity.msg.PollMsg; +import com.thankjava.wqq.entity.msg.SendMsg; +import com.thankjava.wqq.extend.NotifyListener; + +public class MessageListener implements NotifyListener { + + @Override + public void handler(SmartQQClient smartQQClient, PollMsg pollMsg) { + switch (pollMsg.getMsgType()) { + case message: + smartQQClient.sendMsg(new SendMsg(pollMsg, "I Have Got Your Msg: `Friend`")); + break; + case group_message: + smartQQClient.sendMsg(new SendMsg(pollMsg, "I Have Got Your Msg: `Group`")); + break; + case discu_message: + smartQQClient.sendMsg(new SendMsg(pollMsg, "I Have Got Your Msg: `Discu`")); + break; + } + } + + // sendMsg 接口能通过pollMsg得到msg的类型,然后自动回复该类型的msg +// @Override +// public void handler(SmartQQClient smartQQClient, PollMsg pollMsg) { +// smartQQClient.sendMsg(new SendMsg(pollMsg, "I Have Got Your Msg")); +// } + +} diff --git a/src/test/java/com/thankjava/wqq/test/qq/TestSmartQQ.java b/src/test/java/com/thankjava/wqq/test/qq/TestSmartQQ.java index dc4cb73..846f628 100644 --- a/src/test/java/com/thankjava/wqq/test/qq/TestSmartQQ.java +++ b/src/test/java/com/thankjava/wqq/test/qq/TestSmartQQ.java @@ -31,7 +31,7 @@ public static void main(String[] args) { SmartQQClientBuilder builder = SmartQQClientBuilder.custom( // 注册一个通知事件的处理器,它将在SmartQQClient获得到相关信息时被调用执行 - new MessageHandler() + new MessageListener() );