Skip to content
This repository has been archived by the owner on Aug 15, 2019. It is now read-only.

Commit

Permalink
预准备1.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Acexy committed Oct 30, 2018
1 parent 12d3aa7 commit 21642cc
Show file tree
Hide file tree
Showing 27 changed files with 885 additions and 965 deletions.
9 changes: 6 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.thankjava.wqq</groupId>
<artifactId>smartqq-agreement-core</artifactId>
<version>1.1.2</version>
<version>1.2.0</version>

<parent>
<groupId>org.sonatype.oss</groupId>
Expand All @@ -19,7 +19,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

<fast-toolkit.version>1.0.10</fast-toolkit.version>
<fast-toolkit.version>1.1.0</fast-toolkit.version>
<httpasyncclient.version>4.1.4</httpasyncclient.version>
<fastjson.version>1.2.49</fastjson.version>
<org.slf4j.version>1.7.25</org.slf4j.version>
Expand Down Expand Up @@ -122,17 +122,20 @@
<distribution>repo</distribution>
</license>
</licenses>

<scm>
<tag>master</tag>
<url>git@github.com:thankjava/smartqq-agreement-core.git</url>
<connection>scm:git@github.com:thankjava/smartqq-agreement-core.git</connection>
<developerConnection>scm:git:git@github.com:thankjava/smartqq-agreement-core.git</developerConnection>
</scm>

<developers>
<developer>
<name>acexy</name>
<email>acexy@thankjava.com</email>
<organization>Thankjava</organization>
<organization>Lazy-Koala</organization>
</developer>
</developers>

</project>
16 changes: 9 additions & 7 deletions src/main/java/com/thankjava/wqq/SmartQQClientBuilder.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.thankjava.wqq;

import com.thankjava.toolkit.reflect.ReflectHelper;
import com.thankjava.toolkit.core.reflect.ReflectUtil;
import com.thankjava.wqq.consts.ConfigParams;
import com.thankjava.wqq.core.action.LoginAction;
import com.thankjava.wqq.entity.enums.LoginResultStatus;
Expand All @@ -17,11 +17,11 @@
*/
public class SmartQQClientBuilder {

private static SmartQQClient smartQQClient;

private SmartQQClientBuilder() {
}

private static SmartQQClient smartQQClient;

/**
* 声明需要自定义参数化 SmartQQClient
*
Expand All @@ -36,7 +36,7 @@ public static SmartQQClientBuilder custom(NotifyListener notifyListener) {
throw new NullPointerException("notifyListener can not be null");
}

ReflectHelper.setFieldVal(smartQQClient, "notifyListener", notifyListener);
ReflectUtil.setFieldVal(smartQQClient, "notifyListener", notifyListener);

return new SmartQQClientBuilder();
}
Expand Down Expand Up @@ -77,6 +77,7 @@ public SmartQQClientBuilder setAutoRefreshQrcode() {

/**
* 当系统计算出登陆状态异常时会重新登录,连续异常到限定阀值后放弃
*
* @param times
* @return
*/
Expand All @@ -90,11 +91,12 @@ public SmartQQClientBuilder setAutoLoginMaxRetryTimes(int times) {

/**
* 注册一个掉线通知
*
* @param offlineListener
* @return
*/
public SmartQQClientBuilder setOffLineListener(CallBackListener offlineListener) {
ReflectHelper.setFieldVal(smartQQClient, "offlineListener", offlineListener);
ReflectUtil.setFieldVal(smartQQClient, "offlineListener", offlineListener);
return this;
}

Expand All @@ -107,7 +109,7 @@ public SmartQQClientBuilder setOffLineListener(CallBackListener offlineListener)
public void createAndLogin(final CallBackListener getQrListener, final CallBackListener loginListener) {

if (getQrListener == null || loginListener == null) {
throw new NullPointerException("listener can not be null");
throw new NullPointerException("listener can not be null");
}

LoginAction loginAction = ActionFactory.getInstance(LoginAction.class);
Expand All @@ -116,7 +118,7 @@ public void createAndLogin(final CallBackListener getQrListener, final CallBackL

@Override
public void onListener(ActionListener actionListener) {
loginListener.onListener(new ActionListener(new LoginResult(smartQQClient, (LoginResultStatus)actionListener.getData())));
loginListener.onListener(new ActionListener(new LoginResult(smartQQClient, (LoginResultStatus) actionListener.getData())));
}

});
Expand Down
21 changes: 9 additions & 12 deletions src/main/java/com/thankjava/wqq/core/action/GetInfoAction.java
Original file line number Diff line number Diff line change
@@ -1,26 +1,20 @@
package com.thankjava.wqq.core.action;

import com.thankjava.wqq.extend.ActionListener;
import com.thankjava.wqq.extend.CallBackListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.thankjava.toolkit3d.bean.http.AsyncResponse;
import com.thankjava.wqq.consts.ConfigParams;
import com.thankjava.wqq.core.request.RequestBuilder;
import com.thankjava.wqq.core.request.api.GetDiscusList;
import com.thankjava.wqq.core.request.api.GetGroupNameListMask2;
import com.thankjava.wqq.core.request.api.GetOnlineBuddies2;
import com.thankjava.wqq.core.request.api.GetRecentList2;
import com.thankjava.wqq.core.request.api.GetSelfInfo2;
import com.thankjava.wqq.core.request.api.GetUserFriends2;
import com.thankjava.wqq.core.request.api.*;
import com.thankjava.wqq.entity.Session;
import com.thankjava.wqq.entity.wqq.DetailedInfo;
import com.thankjava.wqq.entity.wqq.DiscusList;
import com.thankjava.wqq.entity.wqq.FriendsList;
import com.thankjava.wqq.entity.wqq.GroupsList;
import com.thankjava.wqq.extend.ActionListener;
import com.thankjava.wqq.extend.CallBackListener;
import com.thankjava.wqq.factory.RequestFactory;
import com.thankjava.wqq.util.JSON2Entity;
import com.thankjava.toolkit3d.http.async.entity.AsyncResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class GetInfoAction {

Expand Down Expand Up @@ -199,6 +193,7 @@ public DiscusList getDiscusList() {

/**
* 异步获取讨论组信息
*
* @param callBackListener
* @param tryTimes
*/
Expand Down Expand Up @@ -260,6 +255,7 @@ public GroupsList getGroupsList() {

/**
* 异步获取群组列表
*
* @param callBackListener
* @param tryTimes
*/
Expand Down Expand Up @@ -324,6 +320,7 @@ public DetailedInfo getSelfInfo() {

/**
* 异步获取个人信息
*
* @param callBackListener
* @param tryTimes
*/
Expand Down
34 changes: 14 additions & 20 deletions src/main/java/com/thankjava/wqq/core/action/LoginAction.java
Original file line number Diff line number Diff line change
@@ -1,33 +1,27 @@
package com.thankjava.wqq.core.action;

import java.io.ByteArrayInputStream;
import java.io.IOException;

import javax.imageio.ImageIO;

import com.thankjava.wqq.entity.enums.LoginResultStatus;
import com.thankjava.wqq.extend.ActionListener;
import org.apache.http.cookie.Cookie;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.thankjava.toolkit3d.http.async.entity.AsyncResponse;
import com.alibaba.fastjson.JSONObject;
import com.thankjava.toolkit3d.bean.http.AsyncResponse;
import com.thankjava.wqq.consts.ConfigParams;
import com.thankjava.wqq.consts.ConstsParams;
import com.thankjava.wqq.consts.DataResRegx;
import com.thankjava.wqq.core.event.MsgPollEvent;
import com.thankjava.wqq.core.request.RequestBuilder;
import com.thankjava.wqq.core.request.api.CheckLoginQRcodeStatus;
import com.thankjava.wqq.core.request.api.CheckSig;
import com.thankjava.wqq.core.request.api.GetLoginQRcode;
import com.thankjava.wqq.core.request.api.GetVfWebqq;
import com.thankjava.wqq.core.request.api.Login2;
import com.thankjava.wqq.core.request.api.*;
import com.thankjava.wqq.entity.Session;
import com.thankjava.wqq.entity.wqq.FriendsList;
import com.thankjava.wqq.entity.enums.LoginResultStatus;
import com.thankjava.wqq.extend.ActionListener;
import com.thankjava.wqq.extend.CallBackListener;
import com.thankjava.wqq.factory.ActionFactory;
import com.thankjava.wqq.factory.RequestFactory;
import com.thankjava.wqq.util.RegexUtil;
import com.alibaba.fastjson.JSONObject;
import org.apache.http.cookie.Cookie;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.imageio.ImageIO;
import java.io.ByteArrayInputStream;
import java.io.IOException;

public class LoginAction {

Expand Down Expand Up @@ -215,7 +209,7 @@ public void onListener(ActionListener actionListener) {
public void onListener(ActionListener actionListener) {
if (actionListener.getData() != null) {
logger.debug("获取群列表成功");
}else {
} else {
logger.error("获取群列表失败");
}
}
Expand All @@ -226,7 +220,7 @@ public void onListener(ActionListener actionListener) {
public void onListener(ActionListener actionListener) {
if (actionListener.getData() != null) {
logger.debug("获取个人信息成功");
}else {
} else {
logger.error("获取个人信息失败");
}
}
Expand Down
24 changes: 10 additions & 14 deletions src/main/java/com/thankjava/wqq/core/event/MsgPollEvent.java
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
package com.thankjava.wqq.core.event;

import com.thankjava.toolkit.reflect.ReflectHelper;
import com.thankjava.toolkit.core.reflect.ReflectUtil;
import com.thankjava.toolkit3d.bean.http.AsyncResponse;
import com.thankjava.wqq.WQQClient;
import com.thankjava.wqq.consts.ConfigParams;
import com.thankjava.wqq.core.action.LoginAction;
import com.thankjava.wqq.extend.ActionListener;
import com.thankjava.wqq.factory.ActionFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.thankjava.toolkit3d.http.async.entity.AsyncResponse;
import com.thankjava.wqq.WQQClient;
import com.thankjava.wqq.core.request.RequestBuilder;
import com.thankjava.wqq.core.request.api.Poll2;
import com.thankjava.wqq.entity.Session;
import com.thankjava.wqq.entity.enums.PullMsgStatus;
import com.thankjava.wqq.entity.msg.PollMsg;
import com.thankjava.wqq.entity.sys.MonitoringData;
import com.thankjava.wqq.extend.ActionListener;
import com.thankjava.wqq.extend.CallBackListener;
import com.thankjava.wqq.factory.ActionFactory;
import com.thankjava.wqq.factory.RequestFactory;
import com.thankjava.wqq.util.JSON2Entity;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.lang.reflect.Method;

Expand All @@ -27,14 +27,10 @@
public class MsgPollEvent {

private static final Logger logger = LoggerFactory.getLogger(MsgPollEvent.class);

private static Session session = Session.getSession();
private RequestBuilder poll2 = RequestFactory.getInstance(Poll2.class);

private LoginAction loginAction = ActionFactory.getInstance(LoginAction.class);


private static Session session = Session.getSession();

public void poll() {

poll2.doRequest(new CallBackListener() {
Expand Down Expand Up @@ -88,10 +84,10 @@ private boolean doExceptionCheck(PullMsgStatus pullMsgStatus) {
// 重置监控数据
session.resetMonitoringData();
try {
Method method = ReflectHelper.getMethod(LoginAction.class, "beginLogin");
Method method = ReflectUtil.getMethod(LoginAction.class, "beginLogin");
int retryTimes = ConfigParams.AUTO_RE_LOGIN_RETRY_MAX_TIME;
while (retryTimes > 0) {
boolean flag = (boolean) ReflectHelper.invokeMethod(loginAction, method);
boolean flag = (boolean) ReflectUtil.invokeMethod(loginAction, method);
if (flag) {
logger.debug("执行重连完成");
break;
Expand Down
43 changes: 21 additions & 22 deletions src/main/java/com/thankjava/wqq/core/request/RequestBuilder.java
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@

package com.thankjava.wqq.core.request;

import com.thankjava.toolkit3d.http.async.entity.AsyncResponse;
import com.thankjava.wqq.extend.CallBackListener;

public interface RequestBuilder {

/**
* 请求腾讯服务器 得到请求结果
* <p>Function: doRequest</p>
* <p>Description: </p>
*
* @param listener 回调函数 如果回调函数为空 则通过 return 返回请求结果
* @return 如果没有传入回调函数则结果将通过该参数返回, 如果传入了回调函数则返回值为null
* @author acexy@thankjava.com
* @date 2016年12月19日 下午3:05:37
* @version 1.0
*/
public AsyncResponse doRequest(CallBackListener listener);

}
package com.thankjava.wqq.core.request;

import com.thankjava.toolkit3d.bean.http.AsyncResponse;
import com.thankjava.wqq.extend.CallBackListener;

public interface RequestBuilder {

/**
* 请求腾讯服务器 得到请求结果
* <p>Function: doRequest</p>
* <p>Description: </p>
*
* @param listener 回调函数 如果回调函数为空 则通过 return 返回请求结果
* @return 如果没有传入回调函数则结果将通过该参数返回, 如果传入了回调函数则返回值为null
* @author acexy@thankjava.com
* @date 2016年12月19日 下午3:05:37
* @version 1.0
*/
public AsyncResponse doRequest(CallBackListener listener);

}
Loading

0 comments on commit 21642cc

Please sign in to comment.