Function: doRequest
- *Description:
- * - * @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 { + + /** + * 请求腾讯服务器 得到请求结果 + *Function: doRequest
+ *Description:
+ * + * @param listener 回调函数 如果回调函数为空 则通过 return 返回请求结果 + * @return 如果没有传入回调函数则结果将通过该参数返回, 如果传入了回调函数则返回值为null + * @author acexy@thankjava.com + * @date 2016年12月19日 下午3:05:37 + * @version 1.0 + */ + public AsyncResponse doRequest(CallBackListener listener); + +} 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 94d058a..d8dd5dd 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 @@ -1,19 +1,18 @@ package com.thankjava.wqq.core.request.aop; -import java.lang.reflect.Method; - -import com.thankjava.toolkit3d.http.async.entity.AsyncResponse; -import com.thankjava.toolkit3d.http.async.entity.AsyncResponseCallback; +import com.thankjava.toolkit.bean.aop.entity.AopArgs; +import com.thankjava.toolkit.core.reflect.ReflectUtil; +import com.thankjava.toolkit3d.bean.http.AsyncRequest; +import com.thankjava.toolkit3d.bean.http.AsyncResponse; +import com.thankjava.toolkit3d.bean.http.AsyncResponseCallback; +import com.thankjava.toolkit3d.core.http.AsyncHttpClient; +import com.thankjava.wqq.core.request.api.BaseHttpService; +import com.thankjava.wqq.extend.ActionListener; +import com.thankjava.wqq.extend.CallBackListener; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.thankjava.toolkit3d.aop.entity.AopParam; -import com.thankjava.toolkit.reflect.ReflectHelper; -import com.thankjava.toolkit3d.http.async.AsyncHttpClient; -import com.thankjava.toolkit3d.http.async.entity.AsyncRequest; -import com.thankjava.wqq.core.request.api.BaseHttpService; -import com.thankjava.wqq.extend.CallBackListener; -import com.thankjava.wqq.extend.ActionListener; +import java.lang.reflect.Method; public class DoRequest { @@ -23,19 +22,19 @@ public class DoRequest { private static AsyncHttpClient asyncHttpClient = BaseHttpService.asyncHttpClient; - public AopParam doRequest(AopParam aopParam) { + public void doRequest(AopArgs aopArgs) { // 指定代理的函数不要被执行 - aopParam.setInvokeProxyMethod(false); + aopArgs.setInvokeProxyMethod(false); // 获取被代理的函数的参数列 - final CallBackListener listener = (CallBackListener) aopParam.getParams()[0]; + final CallBackListener listener = (CallBackListener) aopArgs.getInvokeArgs()[0]; // 执行buildRequestParams 得到请求的参数体 - Object proxyInstance = aopParam.getProxyInstance(); + Object proxyInstance = aopArgs.getProxyInstance(); - Method method = ReflectHelper.getMethod(proxyInstance.getClass(), proxyMethodName); - AsyncRequest asyncRequest = (AsyncRequest) ReflectHelper.invokeMethod(proxyInstance, method); + Method method = ReflectUtil.getMethod(proxyInstance.getClass(), proxyMethodName); + AsyncRequest asyncRequest = (AsyncRequest) ReflectUtil.invokeMethod(proxyInstance, method); if (listener != null) { @@ -68,15 +67,12 @@ public void cancelled() { } else { try { - aopParam.setResult(asyncHttpClient.syncRequestWithSession(asyncRequest)); + aopArgs.setReturnResult(asyncHttpClient.syncRequestWithSession(asyncRequest)); } catch (Throwable e) { - aopParam.setResult(null); + aopArgs.setReturnResult(null); logger.error("http request error", e); } } - - // 通过普通的方式返回结果 - return aopParam; } } diff --git a/src/main/java/com/thankjava/wqq/core/request/api/BaseHttpService.java b/src/main/java/com/thankjava/wqq/core/request/api/BaseHttpService.java index a9cdc3d..fca928f 100644 --- a/src/main/java/com/thankjava/wqq/core/request/api/BaseHttpService.java +++ b/src/main/java/com/thankjava/wqq/core/request/api/BaseHttpService.java @@ -1,26 +1,24 @@ package com.thankjava.wqq.core.request.api; -import java.util.concurrent.atomic.AtomicLong; - -import com.thankjava.toolkit3d.http.async.AsyncHttpClient; -import com.thankjava.toolkit3d.http.async.AsyncHttpClientBuilder; -import com.thankjava.toolkit3d.http.async.consts.CookieCheckLevel; -import com.thankjava.toolkit3d.http.async.entity.AsyncRequest; +import com.thankjava.toolkit3d.bean.http.AsyncRequest; +import com.thankjava.toolkit3d.bean.http.CookieCheckLevel; +import com.thankjava.toolkit3d.core.http.AsyncHttpClient; +import com.thankjava.toolkit3d.core.http.AsyncHttpClientBuilder; import com.thankjava.wqq.consts.ConstsParams; import com.thankjava.wqq.core.request.RequestBuilder; import com.thankjava.wqq.entity.Session; -public abstract class BaseHttpService implements RequestBuilder { - - protected final Session session = Session.getSession(); +import java.util.concurrent.atomic.AtomicLong; - protected static final AtomicLong msgId = new AtomicLong(ConstsParams.INIT_MSG_ID); +public abstract class BaseHttpService implements RequestBuilder { public final static AsyncHttpClient asyncHttpClient = new AsyncHttpClientBuilder() .setWithoutSSLCheck() .setCookiePolicyLevel(CookieCheckLevel.BROWSER_COMPATIBILITY) .setCloseWarnLogger() .create(); + protected static final AtomicLong msgId = new AtomicLong(ConstsParams.INIT_MSG_ID); + protected final Session session = Session.getSession(); /** * 关闭AsyncHttpClient diff --git a/src/main/java/com/thankjava/wqq/core/request/api/CheckLoginQRcodeStatus.java b/src/main/java/com/thankjava/wqq/core/request/api/CheckLoginQRcodeStatus.java index 6a7c43d..cc29e07 100644 --- a/src/main/java/com/thankjava/wqq/core/request/api/CheckLoginQRcodeStatus.java +++ b/src/main/java/com/thankjava/wqq/core/request/api/CheckLoginQRcodeStatus.java @@ -1,11 +1,7 @@ package com.thankjava.wqq.core.request.api; -import com.thankjava.toolkit3d.aop.anno.Before; -import com.thankjava.toolkit3d.http.async.consts.HttpMethod; -import com.thankjava.toolkit3d.http.async.entity.Headers; -import com.thankjava.toolkit3d.http.async.entity.Parameters; -import com.thankjava.toolkit3d.http.async.entity.AsyncResponse; -import com.thankjava.toolkit3d.http.async.entity.AsyncRequest; +import com.thankjava.toolkit.bean.aop.anno.Before; +import com.thankjava.toolkit3d.bean.http.*; import com.thankjava.wqq.consts.RequestUrls; import com.thankjava.wqq.core.request.aop.DoRequest; import com.thankjava.wqq.extend.CallBackListener; diff --git a/src/main/java/com/thankjava/wqq/core/request/api/CheckSig.java b/src/main/java/com/thankjava/wqq/core/request/api/CheckSig.java index 7e7be05..678008a 100644 --- a/src/main/java/com/thankjava/wqq/core/request/api/CheckSig.java +++ b/src/main/java/com/thankjava/wqq/core/request/api/CheckSig.java @@ -1,26 +1,26 @@ -package com.thankjava.wqq.core.request.api; - -import com.thankjava.toolkit3d.aop.anno.Before; -import com.thankjava.toolkit3d.http.async.consts.HttpMethod; -import com.thankjava.toolkit3d.http.async.entity.AsyncRequest; -import com.thankjava.toolkit3d.http.async.entity.AsyncResponse; -import com.thankjava.wqq.core.request.aop.DoRequest; -import com.thankjava.wqq.extend.CallBackListener; - -public class CheckSig extends BaseHttpService { - - @Override - @Before(cutClass = DoRequest.class, cutMethod = "doRequest") - public AsyncResponse doRequest(CallBackListener listener) { - return null; - } - - @Override - protected AsyncRequest buildRequestParams() { - return new AsyncRequest( - session.getCheckSigUrl(), - HttpMethod.get - ); - } - -} +package com.thankjava.wqq.core.request.api; + +import com.thankjava.toolkit.bean.aop.anno.Before; +import com.thankjava.toolkit3d.bean.http.AsyncRequest; +import com.thankjava.toolkit3d.bean.http.AsyncResponse; +import com.thankjava.toolkit3d.bean.http.HttpMethod; +import com.thankjava.wqq.core.request.aop.DoRequest; +import com.thankjava.wqq.extend.CallBackListener; + +public class CheckSig extends BaseHttpService { + + @Override + @Before(cutClass = DoRequest.class, cutMethod = "doRequest") + public AsyncResponse doRequest(CallBackListener listener) { + return null; + } + + @Override + protected AsyncRequest buildRequestParams() { + return new AsyncRequest( + session.getCheckSigUrl(), + HttpMethod.get + ); + } + +} diff --git a/src/main/java/com/thankjava/wqq/core/request/api/GetDiscusList.java b/src/main/java/com/thankjava/wqq/core/request/api/GetDiscusList.java index ff50120..a9679a2 100644 --- a/src/main/java/com/thankjava/wqq/core/request/api/GetDiscusList.java +++ b/src/main/java/com/thankjava/wqq/core/request/api/GetDiscusList.java @@ -1,38 +1,34 @@ -package com.thankjava.wqq.core.request.api; - -import com.thankjava.toolkit3d.aop.anno.Before; -import com.thankjava.toolkit3d.http.async.consts.HttpMethod; -import com.thankjava.toolkit3d.http.async.entity.Headers; -import com.thankjava.toolkit3d.http.async.entity.Parameters; -import com.thankjava.toolkit3d.http.async.entity.AsyncRequest; -import com.thankjava.toolkit3d.http.async.entity.AsyncResponse; -import com.thankjava.wqq.consts.ConstsParams; -import com.thankjava.wqq.consts.RequestUrls; -import com.thankjava.wqq.core.request.aop.DoRequest; -import com.thankjava.wqq.extend.CallBackListener; - -public class GetDiscusList extends BaseHttpService { - - @Override - @Before(cutClass = DoRequest.class, cutMethod = "doRequest") - public AsyncResponse doRequest(CallBackListener listener) { - return null; - } - - @Override - protected AsyncRequest buildRequestParams() { - Parameters params = new Parameters("clientid", String.valueOf(ConstsParams.CLIENT_ID)); - params.append("psessionid", session.getPsessionid()); - params.append("vfwebqq", session.getVfwebqq()); - params.append("t", String.valueOf(System.currentTimeMillis() / 1000)); - - Headers headers = new Headers("Referer", RequestUrls.referer_common.url); - return new AsyncRequest( - RequestUrls.get_discus_list.url, - HttpMethod.get, - params, - headers - ); - } - -} +package com.thankjava.wqq.core.request.api; + +import com.thankjava.toolkit.bean.aop.anno.Before; +import com.thankjava.toolkit3d.bean.http.*; +import com.thankjava.wqq.consts.ConstsParams; +import com.thankjava.wqq.consts.RequestUrls; +import com.thankjava.wqq.core.request.aop.DoRequest; +import com.thankjava.wqq.extend.CallBackListener; + +public class GetDiscusList extends BaseHttpService { + + @Override + @Before(cutClass = DoRequest.class, cutMethod = "doRequest") + public AsyncResponse doRequest(CallBackListener listener) { + return null; + } + + @Override + protected AsyncRequest buildRequestParams() { + Parameters params = new Parameters("clientid", String.valueOf(ConstsParams.CLIENT_ID)); + params.append("psessionid", session.getPsessionid()); + params.append("vfwebqq", session.getVfwebqq()); + params.append("t", String.valueOf(System.currentTimeMillis() / 1000)); + + Headers headers = new Headers("Referer", RequestUrls.referer_common.url); + return new AsyncRequest( + RequestUrls.get_discus_list.url, + HttpMethod.get, + params, + headers + ); + } + +} diff --git a/src/main/java/com/thankjava/wqq/core/request/api/GetGroupNameListMask2.java b/src/main/java/com/thankjava/wqq/core/request/api/GetGroupNameListMask2.java index 629dce9..e512bef 100644 --- a/src/main/java/com/thankjava/wqq/core/request/api/GetGroupNameListMask2.java +++ b/src/main/java/com/thankjava/wqq/core/request/api/GetGroupNameListMask2.java @@ -1,34 +1,29 @@ -package com.thankjava.wqq.core.request.api; - -import com.thankjava.toolkit3d.aop.anno.Before; -import com.thankjava.toolkit3d.http.async.consts.HttpMethod; -import com.thankjava.toolkit3d.http.async.entity.AsyncRequest; -import com.thankjava.toolkit3d.http.async.entity.AsyncResponse; -import com.thankjava.toolkit3d.http.async.entity.Headers; -import com.thankjava.toolkit3d.http.async.entity.Parameters; -import com.thankjava.wqq.consts.RequestUrls; -import com.thankjava.wqq.core.request.aop.DoRequest; -import com.thankjava.wqq.extend.CallBackListener; -import com.thankjava.wqq.util.WqqEncryptor; - -import com.alibaba.fastjson.JSONObject; - -public class GetGroupNameListMask2 extends BaseHttpService { - - @Override - @Before(cutClass = DoRequest.class, cutMethod = "doRequest") - public AsyncResponse doRequest(CallBackListener listener) { - return null; - } - - @Override - protected AsyncRequest buildRequestParams() { - JSONObject jsonObject = new JSONObject(); - jsonObject.put("vfwebqq", session.getVfwebqq()); - jsonObject.put("hash", WqqEncryptor.hash(String.valueOf(session.getUin()), session.getPtwebqq())); - Parameters params = new Parameters("r", jsonObject.toJSONString()); - Headers headers = new Headers("Referer", RequestUrls.referer_common.url); - return new AsyncRequest(RequestUrls.get_group_name_list_mask2.url, HttpMethod.post, params, headers); - } - -} +package com.thankjava.wqq.core.request.api; + +import com.alibaba.fastjson.JSONObject; +import com.thankjava.toolkit.bean.aop.anno.Before; +import com.thankjava.toolkit3d.bean.http.*; +import com.thankjava.wqq.consts.RequestUrls; +import com.thankjava.wqq.core.request.aop.DoRequest; +import com.thankjava.wqq.extend.CallBackListener; +import com.thankjava.wqq.util.WqqEncryptor; + +public class GetGroupNameListMask2 extends BaseHttpService { + + @Override + @Before(cutClass = DoRequest.class, cutMethod = "doRequest") + public AsyncResponse doRequest(CallBackListener listener) { + return null; + } + + @Override + protected AsyncRequest buildRequestParams() { + JSONObject jsonObject = new JSONObject(); + jsonObject.put("vfwebqq", session.getVfwebqq()); + jsonObject.put("hash", WqqEncryptor.hash(String.valueOf(session.getUin()), session.getPtwebqq())); + Parameters params = new Parameters("r", jsonObject.toJSONString()); + Headers headers = new Headers("Referer", RequestUrls.referer_common.url); + return new AsyncRequest(RequestUrls.get_group_name_list_mask2.url, HttpMethod.post, params, headers); + } + +} diff --git a/src/main/java/com/thankjava/wqq/core/request/api/GetLoginQRcode.java b/src/main/java/com/thankjava/wqq/core/request/api/GetLoginQRcode.java index 62a36a5..7dc2e9b 100644 --- a/src/main/java/com/thankjava/wqq/core/request/api/GetLoginQRcode.java +++ b/src/main/java/com/thankjava/wqq/core/request/api/GetLoginQRcode.java @@ -1,45 +1,47 @@ -package com.thankjava.wqq.core.request.api; - -import com.thankjava.toolkit3d.aop.anno.Before; -import com.thankjava.toolkit3d.http.async.consts.HttpMethod; -import com.thankjava.toolkit3d.http.async.entity.Parameters; -import com.thankjava.toolkit3d.http.async.entity.AsyncResponse; -import com.thankjava.toolkit3d.http.async.entity.AsyncRequest; -import com.thankjava.wqq.consts.ConstsParams; -import com.thankjava.wqq.consts.RequestUrls; -import com.thankjava.wqq.core.request.aop.DoRequest; -import com.thankjava.wqq.extend.CallBackListener; - -/** - * 获取登录二维码 -*Function: GetLoginQRcode
-*Description:
-* @author acexy@thankjava.com -* @date 2016年12月13日 下午5:53:53 -* @version 1.0 - */ -public class GetLoginQRcode extends BaseHttpService{ - - @Override - protected AsyncRequest buildRequestParams() { - Parameters params = new Parameters("appid", String.valueOf(ConstsParams.APP_ID)); - params.append("e", "0"); - params.append("l", "M"); - params.append("s", "5"); - params.append("d", "72"); - params.append("v", "4"); - params.append("4", String.valueOf(Math.random())); - - return new AsyncRequest( - RequestUrls.get_login_qrcode.url, - HttpMethod.get, - params - ); - } - - @Override - @Before(cutClass = DoRequest.class, cutMethod = "doRequest") - public AsyncResponse doRequest(CallBackListener listener) { - return null; - } -} +package com.thankjava.wqq.core.request.api; + +import com.thankjava.toolkit.bean.aop.anno.Before; +import com.thankjava.toolkit3d.bean.http.AsyncRequest; +import com.thankjava.toolkit3d.bean.http.AsyncResponse; +import com.thankjava.toolkit3d.bean.http.HttpMethod; +import com.thankjava.toolkit3d.bean.http.Parameters; +import com.thankjava.wqq.consts.ConstsParams; +import com.thankjava.wqq.consts.RequestUrls; +import com.thankjava.wqq.core.request.aop.DoRequest; +import com.thankjava.wqq.extend.CallBackListener; + +/** + * 获取登录二维码 + *Function: GetLoginQRcode
+ *Description:
+ * + * @author acexy@thankjava.com + * @version 1.0 + * @date 2016年12月13日 下午5:53:53 + */ +public class GetLoginQRcode extends BaseHttpService { + + + @Override + @Before(cutClass = DoRequest.class, cutMethod = "doRequest") + public AsyncResponse doRequest(CallBackListener listener) { + return null; + } + + @Override + protected AsyncRequest buildRequestParams() { + Parameters params = new Parameters("appid", String.valueOf(ConstsParams.APP_ID)); + params.append("e", "0"); + params.append("l", "M"); + params.append("s", "5"); + params.append("d", "72"); + params.append("v", "4"); + params.append("4", String.valueOf(Math.random())); + + return new AsyncRequest( + RequestUrls.get_login_qrcode.url, + HttpMethod.get, + params + ); + } +} diff --git a/src/main/java/com/thankjava/wqq/core/request/api/GetOnlineBuddies2.java b/src/main/java/com/thankjava/wqq/core/request/api/GetOnlineBuddies2.java index a02c009..73b7a0e 100644 --- a/src/main/java/com/thankjava/wqq/core/request/api/GetOnlineBuddies2.java +++ b/src/main/java/com/thankjava/wqq/core/request/api/GetOnlineBuddies2.java @@ -1,38 +1,34 @@ -package com.thankjava.wqq.core.request.api; - -import com.thankjava.toolkit3d.aop.anno.Before; -import com.thankjava.toolkit3d.http.async.consts.HttpMethod; -import com.thankjava.toolkit3d.http.async.entity.Headers; -import com.thankjava.toolkit3d.http.async.entity.Parameters; -import com.thankjava.toolkit3d.http.async.entity.AsyncRequest; -import com.thankjava.toolkit3d.http.async.entity.AsyncResponse; -import com.thankjava.wqq.consts.ConstsParams; -import com.thankjava.wqq.consts.RequestUrls; -import com.thankjava.wqq.core.request.aop.DoRequest; -import com.thankjava.wqq.extend.CallBackListener; - -public class GetOnlineBuddies2 extends BaseHttpService{ - - @Override - @Before(cutClass = DoRequest.class, cutMethod = "doRequest") - public AsyncResponse doRequest(CallBackListener listener) { - return null; - } - - @Override - protected AsyncRequest buildRequestParams() { - - Parameters params = new Parameters("vfwebqq", session.getVfwebqq()); - params.append("clientid", String.valueOf(ConstsParams.CLIENT_ID)); - params.append("psessionid", session.getPsessionid()); - params.append("t", String.valueOf(System.currentTimeMillis() / 1000)); - Headers headers = new Headers("Referer", RequestUrls.referer_common.url); - return new AsyncRequest( - RequestUrls.get_online_buddies2.url, - HttpMethod.get, - params, - headers - ); - } - -} +package com.thankjava.wqq.core.request.api; + +import com.thankjava.toolkit.bean.aop.anno.Before; +import com.thankjava.toolkit3d.bean.http.*; +import com.thankjava.wqq.consts.ConstsParams; +import com.thankjava.wqq.consts.RequestUrls; +import com.thankjava.wqq.core.request.aop.DoRequest; +import com.thankjava.wqq.extend.CallBackListener; + +public class GetOnlineBuddies2 extends BaseHttpService { + + @Override + @Before(cutClass = DoRequest.class, cutMethod = "doRequest") + public AsyncResponse doRequest(CallBackListener listener) { + return null; + } + + @Override + protected AsyncRequest buildRequestParams() { + + Parameters params = new Parameters("vfwebqq", session.getVfwebqq()); + params.append("clientid", String.valueOf(ConstsParams.CLIENT_ID)); + params.append("psessionid", session.getPsessionid()); + params.append("t", String.valueOf(System.currentTimeMillis() / 1000)); + Headers headers = new Headers("Referer", RequestUrls.referer_common.url); + return new AsyncRequest( + RequestUrls.get_online_buddies2.url, + HttpMethod.get, + params, + headers + ); + } + +} diff --git a/src/main/java/com/thankjava/wqq/core/request/api/GetRecentList2.java b/src/main/java/com/thankjava/wqq/core/request/api/GetRecentList2.java index 9381a9f..207acd0 100644 --- a/src/main/java/com/thankjava/wqq/core/request/api/GetRecentList2.java +++ b/src/main/java/com/thankjava/wqq/core/request/api/GetRecentList2.java @@ -1,42 +1,37 @@ -package com.thankjava.wqq.core.request.api; - -import com.thankjava.toolkit3d.aop.anno.Before; -import com.thankjava.toolkit3d.http.async.consts.HttpMethod; -import com.thankjava.toolkit3d.http.async.entity.Headers; -import com.thankjava.toolkit3d.http.async.entity.Parameters; -import com.thankjava.toolkit3d.http.async.entity.AsyncRequest; -import com.thankjava.toolkit3d.http.async.entity.AsyncResponse; -import com.thankjava.wqq.consts.ConstsParams; -import com.thankjava.wqq.consts.RequestUrls; -import com.thankjava.wqq.core.request.aop.DoRequest; -import com.thankjava.wqq.extend.CallBackListener; - -import com.alibaba.fastjson.JSONObject; - -public class GetRecentList2 extends BaseHttpService { - - @Override - @Before(cutClass = DoRequest.class, cutMethod = "doRequest") - public AsyncResponse doRequest(CallBackListener listener) { - return null; - } - - @Override - protected AsyncRequest buildRequestParams() { - - JSONObject jsonObject = new JSONObject(); - jsonObject.put("vfwebqq", session.getVfwebqq()); - jsonObject.put("clientid", ConstsParams.CLIENT_ID); - jsonObject.put("psessionid", session.getPsessionid()); - - Parameters params = new Parameters("r", jsonObject.toJSONString()); - Headers headers = new Headers("Referer", RequestUrls.referer_common.url); - return new AsyncRequest( - RequestUrls.get_recent_list2.url, - HttpMethod.post, - params, - headers - ); - } - -} +package com.thankjava.wqq.core.request.api; + +import com.alibaba.fastjson.JSONObject; +import com.thankjava.toolkit.bean.aop.anno.Before; +import com.thankjava.toolkit3d.bean.http.*; +import com.thankjava.wqq.consts.ConstsParams; +import com.thankjava.wqq.consts.RequestUrls; +import com.thankjava.wqq.core.request.aop.DoRequest; +import com.thankjava.wqq.extend.CallBackListener; + +public class GetRecentList2 extends BaseHttpService { + + @Override + @Before(cutClass = DoRequest.class, cutMethod = "doRequest") + public AsyncResponse doRequest(CallBackListener listener) { + return null; + } + + @Override + protected AsyncRequest buildRequestParams() { + + JSONObject jsonObject = new JSONObject(); + jsonObject.put("vfwebqq", session.getVfwebqq()); + jsonObject.put("clientid", ConstsParams.CLIENT_ID); + jsonObject.put("psessionid", session.getPsessionid()); + + Parameters params = new Parameters("r", jsonObject.toJSONString()); + Headers headers = new Headers("Referer", RequestUrls.referer_common.url); + return new AsyncRequest( + RequestUrls.get_recent_list2.url, + HttpMethod.post, + params, + headers + ); + } + +} diff --git a/src/main/java/com/thankjava/wqq/core/request/api/GetSelfInfo2.java b/src/main/java/com/thankjava/wqq/core/request/api/GetSelfInfo2.java index 3dc4cfe..5f8b6af 100644 --- a/src/main/java/com/thankjava/wqq/core/request/api/GetSelfInfo2.java +++ b/src/main/java/com/thankjava/wqq/core/request/api/GetSelfInfo2.java @@ -1,34 +1,30 @@ -package com.thankjava.wqq.core.request.api; - -import com.thankjava.toolkit3d.aop.anno.Before; -import com.thankjava.toolkit3d.http.async.consts.HttpMethod; -import com.thankjava.toolkit3d.http.async.entity.Headers; -import com.thankjava.toolkit3d.http.async.entity.Parameters; -import com.thankjava.toolkit3d.http.async.entity.AsyncResponse; -import com.thankjava.toolkit3d.http.async.entity.AsyncRequest; -import com.thankjava.wqq.consts.RequestUrls; -import com.thankjava.wqq.core.request.aop.DoRequest; -import com.thankjava.wqq.extend.CallBackListener; - -public class GetSelfInfo2 extends BaseHttpService { - - @Override - @Before(cutClass = DoRequest.class, cutMethod = "doRequest") - public AsyncResponse doRequest(CallBackListener listener) { - return null; - } - - @Override - protected AsyncRequest buildRequestParams() { - Parameters params = new Parameters("t", String.valueOf(System.currentTimeMillis() / 1000)); - - Headers headers = new Headers("Referer", RequestUrls.referer_common.url); - return new AsyncRequest( - RequestUrls.get_self_info2.url, - HttpMethod.get, - params, - headers - ); - } - -} +package com.thankjava.wqq.core.request.api; + +import com.thankjava.toolkit.bean.aop.anno.Before; +import com.thankjava.toolkit3d.bean.http.*; +import com.thankjava.wqq.consts.RequestUrls; +import com.thankjava.wqq.core.request.aop.DoRequest; +import com.thankjava.wqq.extend.CallBackListener; + +public class GetSelfInfo2 extends BaseHttpService { + + @Override + @Before(cutClass = DoRequest.class, cutMethod = "doRequest") + public AsyncResponse doRequest(CallBackListener listener) { + return null; + } + + @Override + protected AsyncRequest buildRequestParams() { + Parameters params = new Parameters("t", String.valueOf(System.currentTimeMillis() / 1000)); + + Headers headers = new Headers("Referer", RequestUrls.referer_common.url); + return new AsyncRequest( + RequestUrls.get_self_info2.url, + HttpMethod.get, + params, + headers + ); + } + +} diff --git a/src/main/java/com/thankjava/wqq/core/request/api/GetUserFriends2.java b/src/main/java/com/thankjava/wqq/core/request/api/GetUserFriends2.java index 81ab17e..7071d3b 100644 --- a/src/main/java/com/thankjava/wqq/core/request/api/GetUserFriends2.java +++ b/src/main/java/com/thankjava/wqq/core/request/api/GetUserFriends2.java @@ -1,34 +1,29 @@ -package com.thankjava.wqq.core.request.api; - -import com.thankjava.toolkit3d.aop.anno.Before; -import com.thankjava.toolkit3d.http.async.consts.HttpMethod; -import com.thankjava.toolkit3d.http.async.entity.Headers; -import com.thankjava.toolkit3d.http.async.entity.Parameters; -import com.thankjava.toolkit3d.http.async.entity.AsyncResponse; -import com.thankjava.toolkit3d.http.async.entity.AsyncRequest; -import com.thankjava.wqq.consts.RequestUrls; -import com.thankjava.wqq.core.request.aop.DoRequest; -import com.thankjava.wqq.extend.CallBackListener; -import com.thankjava.wqq.util.WqqEncryptor; - -import com.alibaba.fastjson.JSONObject; - -public class GetUserFriends2 extends BaseHttpService { - - @Override - @Before(cutClass = DoRequest.class, cutMethod = "doRequest") - public AsyncResponse doRequest(CallBackListener listener) { - return null; - } - - @Override - protected AsyncRequest buildRequestParams() { - JSONObject jsonObject = new JSONObject(); - jsonObject.put("vfwebqq", session.getVfwebqq()); - jsonObject.put("hash", WqqEncryptor.hash(String.valueOf(session.getUin()), session.getPtwebqq())); - Parameters params = new Parameters("r", jsonObject.toJSONString()); - Headers headers = new Headers("Referer", RequestUrls.referer_common.url); - return new AsyncRequest(RequestUrls.get_user_friends2.url, HttpMethod.post, params, headers); - } - -} +package com.thankjava.wqq.core.request.api; + +import com.alibaba.fastjson.JSONObject; +import com.thankjava.toolkit.bean.aop.anno.Before; +import com.thankjava.toolkit3d.bean.http.*; +import com.thankjava.wqq.consts.RequestUrls; +import com.thankjava.wqq.core.request.aop.DoRequest; +import com.thankjava.wqq.extend.CallBackListener; +import com.thankjava.wqq.util.WqqEncryptor; + +public class GetUserFriends2 extends BaseHttpService { + + @Override + @Before(cutClass = DoRequest.class, cutMethod = "doRequest") + public AsyncResponse doRequest(CallBackListener listener) { + return null; + } + + @Override + protected AsyncRequest buildRequestParams() { + JSONObject jsonObject = new JSONObject(); + jsonObject.put("vfwebqq", session.getVfwebqq()); + jsonObject.put("hash", WqqEncryptor.hash(String.valueOf(session.getUin()), session.getPtwebqq())); + Parameters params = new Parameters("r", jsonObject.toJSONString()); + Headers headers = new Headers("Referer", RequestUrls.referer_common.url); + return new AsyncRequest(RequestUrls.get_user_friends2.url, HttpMethod.post, params, headers); + } + +} diff --git a/src/main/java/com/thankjava/wqq/core/request/api/GetVfWebqq.java b/src/main/java/com/thankjava/wqq/core/request/api/GetVfWebqq.java index 4c43cd2..8cdae31 100644 --- a/src/main/java/com/thankjava/wqq/core/request/api/GetVfWebqq.java +++ b/src/main/java/com/thankjava/wqq/core/request/api/GetVfWebqq.java @@ -1,30 +1,26 @@ -package com.thankjava.wqq.core.request.api; - -import com.thankjava.toolkit3d.aop.anno.Before; -import com.thankjava.toolkit3d.http.async.consts.HttpMethod; -import com.thankjava.toolkit3d.http.async.entity.Headers; -import com.thankjava.toolkit3d.http.async.entity.Parameters; -import com.thankjava.toolkit3d.http.async.entity.AsyncResponse; -import com.thankjava.toolkit3d.http.async.entity.AsyncRequest; -import com.thankjava.wqq.consts.RequestUrls; -import com.thankjava.wqq.core.request.aop.DoRequest; -import com.thankjava.wqq.extend.CallBackListener; - -public class GetVfWebqq extends BaseHttpService { - - @Override - @Before(cutClass = DoRequest.class, cutMethod = "doRequest") - public AsyncResponse doRequest(CallBackListener listener) { - return null; - } - - @Override - protected AsyncRequest buildRequestParams() { - Parameters params = new Parameters("ptwebqq", session.getPtwebqq()); - params.append("clientid", "53999199"); - params.append("psessionid", ""); - params.append("t", String.valueOf(System.currentTimeMillis() / 1000)); - Headers header = new Headers("Referer", RequestUrls.referer_getvfwebqq.url); - return new AsyncRequest(RequestUrls.getvfwebqq.url, HttpMethod.get, params, header); - } -} +package com.thankjava.wqq.core.request.api; + +import com.thankjava.toolkit.bean.aop.anno.Before; +import com.thankjava.toolkit3d.bean.http.*; +import com.thankjava.wqq.consts.RequestUrls; +import com.thankjava.wqq.core.request.aop.DoRequest; +import com.thankjava.wqq.extend.CallBackListener; + +public class GetVfWebqq extends BaseHttpService { + + @Override + @Before(cutClass = DoRequest.class, cutMethod = "doRequest") + public AsyncResponse doRequest(CallBackListener listener) { + return null; + } + + @Override + protected AsyncRequest buildRequestParams() { + Parameters params = new Parameters("ptwebqq", session.getPtwebqq()); + params.append("clientid", "53999199"); + params.append("psessionid", ""); + params.append("t", String.valueOf(System.currentTimeMillis() / 1000)); + Headers header = new Headers("Referer", RequestUrls.referer_getvfwebqq.url); + return new AsyncRequest(RequestUrls.getvfwebqq.url, HttpMethod.get, params, header); + } +} diff --git a/src/main/java/com/thankjava/wqq/core/request/api/Login2.java b/src/main/java/com/thankjava/wqq/core/request/api/Login2.java index 3283389..3ba5fc7 100644 --- a/src/main/java/com/thankjava/wqq/core/request/api/Login2.java +++ b/src/main/java/com/thankjava/wqq/core/request/api/Login2.java @@ -1,36 +1,31 @@ -package com.thankjava.wqq.core.request.api; - -import com.thankjava.toolkit3d.aop.anno.Before; -import com.thankjava.toolkit3d.http.async.consts.HttpMethod; -import com.thankjava.toolkit3d.http.async.entity.AsyncRequest; -import com.thankjava.toolkit3d.http.async.entity.AsyncResponse; -import com.thankjava.toolkit3d.http.async.entity.Headers; -import com.thankjava.toolkit3d.http.async.entity.Parameters; -import com.thankjava.wqq.consts.ConstsParams; -import com.thankjava.wqq.consts.RequestUrls; -import com.thankjava.wqq.core.request.aop.DoRequest; -import com.thankjava.wqq.extend.CallBackListener; - -import com.alibaba.fastjson.JSONObject; - -public class Login2 extends BaseHttpService { - - @Override - @Before(cutClass = DoRequest.class, cutMethod = "doRequest") - public AsyncResponse doRequest(CallBackListener listener) { - return null; - } - - @Override - protected AsyncRequest buildRequestParams() { - JSONObject jsonObject = new JSONObject(); - jsonObject.put("ptwebqq", session.getPtwebqq()); - jsonObject.put("clientid", ConstsParams.CLIENT_ID); - jsonObject.put("psessionid", ""); - jsonObject.put("status", "online"); - Parameters params = new Parameters("r", jsonObject.toJSONString()); - Headers headers = new Headers("Referer", RequestUrls.referer_common.url); - return new AsyncRequest(RequestUrls.login2.url, HttpMethod.post, params, headers); - } - -} +package com.thankjava.wqq.core.request.api; + +import com.alibaba.fastjson.JSONObject; +import com.thankjava.toolkit.bean.aop.anno.Before; +import com.thankjava.toolkit3d.bean.http.*; +import com.thankjava.wqq.consts.ConstsParams; +import com.thankjava.wqq.consts.RequestUrls; +import com.thankjava.wqq.core.request.aop.DoRequest; +import com.thankjava.wqq.extend.CallBackListener; + +public class Login2 extends BaseHttpService { + + @Override + @Before(cutClass = DoRequest.class, cutMethod = "doRequest") + public AsyncResponse doRequest(CallBackListener listener) { + return null; + } + + @Override + protected AsyncRequest buildRequestParams() { + JSONObject jsonObject = new JSONObject(); + jsonObject.put("ptwebqq", session.getPtwebqq()); + jsonObject.put("clientid", ConstsParams.CLIENT_ID); + jsonObject.put("psessionid", ""); + jsonObject.put("status", "online"); + Parameters params = new Parameters("r", jsonObject.toJSONString()); + Headers headers = new Headers("Referer", RequestUrls.referer_common.url); + return new AsyncRequest(RequestUrls.login2.url, HttpMethod.post, params, headers); + } + +} diff --git a/src/main/java/com/thankjava/wqq/core/request/api/Poll2.java b/src/main/java/com/thankjava/wqq/core/request/api/Poll2.java index 0eceead..37cde47 100644 --- a/src/main/java/com/thankjava/wqq/core/request/api/Poll2.java +++ b/src/main/java/com/thankjava/wqq/core/request/api/Poll2.java @@ -1,36 +1,31 @@ -package com.thankjava.wqq.core.request.api; - -import com.thankjava.toolkit3d.aop.anno.Before; -import com.thankjava.toolkit3d.http.async.consts.HttpMethod; -import com.thankjava.toolkit3d.http.async.entity.Headers; -import com.thankjava.toolkit3d.http.async.entity.Parameters; -import com.thankjava.toolkit3d.http.async.entity.AsyncResponse; -import com.thankjava.toolkit3d.http.async.entity.AsyncRequest; -import com.thankjava.wqq.consts.ConstsParams; -import com.thankjava.wqq.consts.RequestUrls; -import com.thankjava.wqq.core.request.aop.DoRequest; -import com.thankjava.wqq.extend.CallBackListener; - -import com.alibaba.fastjson.JSONObject; - -public class Poll2 extends BaseHttpService { - - @Override - @Before(cutClass = DoRequest.class, cutMethod = "doRequest") - public AsyncResponse doRequest(CallBackListener listener) { - return null; - } - - @Override - protected AsyncRequest buildRequestParams() { - JSONObject jsonObject = new JSONObject(); - jsonObject.put("ptwebqq", session.getPtwebqq()); - jsonObject.put("clientid", ConstsParams.CLIENT_ID); - jsonObject.put("psessionid", session.getPsessionid()); - jsonObject.put("key", ""); - Parameters params = new Parameters("r", jsonObject.toJSONString()); - Headers headers = new Headers("Referer", RequestUrls.referer_about_msg.url); - return new AsyncRequest(RequestUrls.poll2.url, HttpMethod.post, params, headers); - } - -} +package com.thankjava.wqq.core.request.api; + +import com.alibaba.fastjson.JSONObject; +import com.thankjava.toolkit.bean.aop.anno.Before; +import com.thankjava.toolkit3d.bean.http.*; +import com.thankjava.wqq.consts.ConstsParams; +import com.thankjava.wqq.consts.RequestUrls; +import com.thankjava.wqq.core.request.aop.DoRequest; +import com.thankjava.wqq.extend.CallBackListener; + +public class Poll2 extends BaseHttpService { + + @Override + @Before(cutClass = DoRequest.class, cutMethod = "doRequest") + public AsyncResponse doRequest(CallBackListener listener) { + return null; + } + + @Override + protected AsyncRequest buildRequestParams() { + JSONObject jsonObject = new JSONObject(); + jsonObject.put("ptwebqq", session.getPtwebqq()); + jsonObject.put("clientid", ConstsParams.CLIENT_ID); + jsonObject.put("psessionid", session.getPsessionid()); + jsonObject.put("key", ""); + Parameters params = new Parameters("r", jsonObject.toJSONString()); + Headers headers = new Headers("Referer", RequestUrls.referer_about_msg.url); + return new AsyncRequest(RequestUrls.poll2.url, HttpMethod.post, params, headers); + } + +} 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 80c69b8..d45ef14 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 @@ -1,48 +1,43 @@ package com.thankjava.wqq.core.request.api; -import com.thankjava.toolkit3d.http.async.consts.HttpMethod; -import com.thankjava.toolkit3d.http.async.entity.Headers; -import com.thankjava.toolkit3d.http.async.entity.Parameters; -import com.thankjava.toolkit3d.http.async.entity.AsyncRequest; -import com.thankjava.toolkit3d.http.async.entity.AsyncResponse; +import com.alibaba.fastjson.JSONObject; +import com.thankjava.toolkit3d.bean.http.*; import com.thankjava.wqq.consts.ConstsParams; import com.thankjava.wqq.consts.RequestUrls; import com.thankjava.wqq.entity.msg.SendMsg; import com.thankjava.wqq.extend.ActionListener; import com.thankjava.wqq.extend.CallBackListener; -import com.alibaba.fastjson.JSONObject; +public class SendBuddyMsg2 extends BaseHttpService { + + private SendMsg sendMsg; -public class SendBuddyMsg2 extends BaseHttpService{ + public SendBuddyMsg2(SendMsg sendMsg) { + this.sendMsg = sendMsg; + } - private SendMsg sendMsg; - - public SendBuddyMsg2(SendMsg sendMsg) { - this.sendMsg = sendMsg; - } - - @Override - public AsyncResponse doRequest(CallBackListener listener) { - if(listener != null){ - listener.onListener(new ActionListener(asyncHttpClient.syncRequestWithSession(buildRequestParams()))); - return null; - }else{ - return asyncHttpClient.syncRequestWithSession(buildRequestParams()); - } - } + @Override + public AsyncResponse doRequest(CallBackListener listener) { + if (listener != null) { + listener.onListener(new ActionListener(asyncHttpClient.syncRequestWithSession(buildRequestParams()))); + return null; + } else { + return asyncHttpClient.syncRequestWithSession(buildRequestParams()); + } + } - @Override - protected AsyncRequest buildRequestParams() { - JSONObject jsonObject = new JSONObject(); - jsonObject.put("to", sendMsg.getTo()); // - jsonObject.put("content", sendMsg.getContent().toSendMsg()); // - jsonObject.put("face", 546); // 这个其实没啥用 - jsonObject.put("clientid", ConstsParams.CLIENT_ID); - jsonObject.put("msg_id", msgId.incrementAndGet()); - jsonObject.put("psessionid", session.getPsessionid()); - Parameters params = new Parameters("r", jsonObject.toJSONString()); - Headers headers = new Headers("Referer", RequestUrls.referer_about_msg.url); - return new AsyncRequest(RequestUrls.send_buddy_msg2.url, HttpMethod.post, params, headers); - } + @Override + protected AsyncRequest buildRequestParams() { + JSONObject jsonObject = new JSONObject(); + jsonObject.put("to", sendMsg.getTo()); // + jsonObject.put("content", sendMsg.getContent().toSendMsg()); // + jsonObject.put("face", 546); // 这个其实没啥用 + jsonObject.put("clientid", ConstsParams.CLIENT_ID); + jsonObject.put("msg_id", msgId.incrementAndGet()); + jsonObject.put("psessionid", session.getPsessionid()); + Parameters params = new Parameters("r", jsonObject.toJSONString()); + Headers headers = new Headers("Referer", RequestUrls.referer_about_msg.url); + return new AsyncRequest(RequestUrls.send_buddy_msg2.url, HttpMethod.post, params, headers); + } } 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 c39aabf..59e7abc 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 @@ -1,48 +1,43 @@ package com.thankjava.wqq.core.request.api; -import com.thankjava.toolkit3d.http.async.consts.HttpMethod; -import com.thankjava.toolkit3d.http.async.entity.Headers; -import com.thankjava.toolkit3d.http.async.entity.Parameters; -import com.thankjava.toolkit3d.http.async.entity.AsyncResponse; -import com.thankjava.toolkit3d.http.async.entity.AsyncRequest; +import com.alibaba.fastjson.JSONObject; +import com.thankjava.toolkit3d.bean.http.*; import com.thankjava.wqq.consts.ConstsParams; import com.thankjava.wqq.consts.RequestUrls; import com.thankjava.wqq.entity.msg.SendMsg; import com.thankjava.wqq.extend.ActionListener; import com.thankjava.wqq.extend.CallBackListener; -import com.alibaba.fastjson.JSONObject; +public class SendDiscuMsg2 extends BaseHttpService { + + private SendMsg sendMsg; -public class SendDiscuMsg2 extends BaseHttpService{ + public SendDiscuMsg2(SendMsg sendMsg) { + this.sendMsg = sendMsg; + } - private SendMsg sendMsg; - - public SendDiscuMsg2(SendMsg sendMsg) { - this.sendMsg = sendMsg; - } - - @Override - public AsyncResponse doRequest(CallBackListener listener) { - if(listener != null){ - listener.onListener(new ActionListener(asyncHttpClient.syncRequestWithSession(buildRequestParams()))); - return null; - }else{ - return asyncHttpClient.syncRequestWithSession(buildRequestParams()); - } - } + @Override + public AsyncResponse doRequest(CallBackListener listener) { + if (listener != null) { + listener.onListener(new ActionListener(asyncHttpClient.syncRequestWithSession(buildRequestParams()))); + return null; + } else { + return asyncHttpClient.syncRequestWithSession(buildRequestParams()); + } + } - @Override - protected AsyncRequest buildRequestParams() { - JSONObject jsonObject = new JSONObject(); - jsonObject.put("did", sendMsg.getDid()); // - jsonObject.put("content", sendMsg.getContent().toSendMsg()); // - jsonObject.put("face", 546); // 这个其实没啥用 - jsonObject.put("clientid", ConstsParams.CLIENT_ID); - jsonObject.put("msg_id", msgId.incrementAndGet()); - jsonObject.put("psessionid", session.getPsessionid()); - Parameters params = new Parameters("r", jsonObject.toJSONString()); - Headers headers = new Headers("Referer", RequestUrls.referer_about_msg.url); - return new AsyncRequest(RequestUrls.send_discu_msg2.url, HttpMethod.post, params, headers); - } + @Override + protected AsyncRequest buildRequestParams() { + JSONObject jsonObject = new JSONObject(); + jsonObject.put("did", sendMsg.getDid()); // + jsonObject.put("content", sendMsg.getContent().toSendMsg()); // + jsonObject.put("face", 546); // 这个其实没啥用 + jsonObject.put("clientid", ConstsParams.CLIENT_ID); + jsonObject.put("msg_id", msgId.incrementAndGet()); + jsonObject.put("psessionid", session.getPsessionid()); + Parameters params = new Parameters("r", jsonObject.toJSONString()); + Headers headers = new Headers("Referer", RequestUrls.referer_about_msg.url); + return new AsyncRequest(RequestUrls.send_discu_msg2.url, HttpMethod.post, params, headers); + } } 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 d62df47..cf4ad79 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 @@ -1,49 +1,44 @@ package com.thankjava.wqq.core.request.api; -import com.thankjava.toolkit3d.http.async.consts.HttpMethod; -import com.thankjava.toolkit3d.http.async.entity.Headers; -import com.thankjava.toolkit3d.http.async.entity.Parameters; -import com.thankjava.toolkit3d.http.async.entity.AsyncResponse; -import com.thankjava.toolkit3d.http.async.entity.AsyncRequest; +import com.alibaba.fastjson.JSONObject; +import com.thankjava.toolkit3d.bean.http.*; import com.thankjava.wqq.consts.ConstsParams; import com.thankjava.wqq.consts.RequestUrls; import com.thankjava.wqq.entity.msg.SendMsg; -import com.thankjava.wqq.extend.CallBackListener; import com.thankjava.wqq.extend.ActionListener; - -import com.alibaba.fastjson.JSONObject; +import com.thankjava.wqq.extend.CallBackListener; public class SendQunMsg2 extends BaseHttpService { - private SendMsg sendMsg; - - public SendQunMsg2(SendMsg sendMsg) { - this.sendMsg = sendMsg; - } - - @Override - public AsyncResponse doRequest(CallBackListener listener) { - if(listener != null){ - ActionListener actionListener = new ActionListener(asyncHttpClient.syncRequestWithSession(buildRequestParams())); - listener.onListener(actionListener); - return null; - }else{ - return asyncHttpClient.syncRequestWithSession(buildRequestParams()); - } - } + private SendMsg sendMsg; + + public SendQunMsg2(SendMsg sendMsg) { + this.sendMsg = sendMsg; + } + + @Override + public AsyncResponse doRequest(CallBackListener listener) { + if (listener != null) { + ActionListener actionListener = new ActionListener(asyncHttpClient.syncRequestWithSession(buildRequestParams())); + listener.onListener(actionListener); + return null; + } else { + return asyncHttpClient.syncRequestWithSession(buildRequestParams()); + } + } - @Override - protected AsyncRequest buildRequestParams() { - JSONObject jsonObject = new JSONObject(); - jsonObject.put("group_uin", sendMsg.getGroupUin()); // - jsonObject.put("content", sendMsg.getContent().toSendMsg()); // - jsonObject.put("face", 546); // 这个其实没啥用 - jsonObject.put("clientid", ConstsParams.CLIENT_ID); - jsonObject.put("msg_id", msgId.incrementAndGet()); - jsonObject.put("psessionid", session.getPsessionid()); - Parameters params = new Parameters("r", jsonObject.toJSONString()); - Headers headers = new Headers("Referer", RequestUrls.referer_about_msg.url); - return new AsyncRequest(RequestUrls.send_qun_msg2.url, HttpMethod.post, params, headers); - } + @Override + protected AsyncRequest buildRequestParams() { + JSONObject jsonObject = new JSONObject(); + jsonObject.put("group_uin", sendMsg.getGroupUin()); // + jsonObject.put("content", sendMsg.getContent().toSendMsg()); // + jsonObject.put("face", 546); // 这个其实没啥用 + jsonObject.put("clientid", ConstsParams.CLIENT_ID); + jsonObject.put("msg_id", msgId.incrementAndGet()); + jsonObject.put("psessionid", session.getPsessionid()); + Parameters params = new Parameters("r", jsonObject.toJSONString()); + Headers headers = new Headers("Referer", RequestUrls.referer_about_msg.url); + return new AsyncRequest(RequestUrls.send_qun_msg2.url, HttpMethod.post, params, headers); + } } diff --git a/src/main/java/com/thankjava/wqq/entity/sys/MonitoringData.java b/src/main/java/com/thankjava/wqq/entity/sys/MonitoringData.java index 3fbeee4..3625896 100644 --- a/src/main/java/com/thankjava/wqq/entity/sys/MonitoringData.java +++ b/src/main/java/com/thankjava/wqq/entity/sys/MonitoringData.java @@ -2,7 +2,7 @@ import java.util.ArrayDeque; -import com.thankjava.toolkit.math.MathUtils; +import com.thankjava.toolkit.core.utils.MathUtil; import com.thankjava.wqq.consts.ConfigParams; public class MonitoringData { @@ -25,6 +25,6 @@ public double getAverageValueOfOneSecond() { long first = frequencyData.getFirst(); long last = frequencyData.getLast(); long timeSecond = (last - first) / 1000; - return MathUtils.divide(ConfigParams.MONITOR_THE_NUMBER_OF_DATA_SAMPLES, timeSecond, 0); + return MathUtil.divide(ConfigParams.MONITOR_THE_NUMBER_OF_DATA_SAMPLES, timeSecond, 0); } } diff --git a/src/main/java/com/thankjava/wqq/factory/RequestFactory.java b/src/main/java/com/thankjava/wqq/factory/RequestFactory.java index f96cbf3..f05f118 100644 --- a/src/main/java/com/thankjava/wqq/factory/RequestFactory.java +++ b/src/main/java/com/thankjava/wqq/factory/RequestFactory.java @@ -1,26 +1,27 @@ -package com.thankjava.wqq.factory; - -import java.util.HashMap; -import java.util.Map; - -import com.thankjava.wqq.core.request.RequestBuilder; - -import com.thankjava.toolkit3d.aop.core.AopProxyFactory; - -public class RequestFactory { - - private RequestFactory(){} - - private static final MapFunction: JSON2Entity
- *Description:
- * - * @author acexy@thankjava.com - * @version 1.0 - * @date 2017年6月14日 下午2:27:34 - */ -public class JSON2Entity { - - private static Logger logger = LoggerFactory.getLogger(JSON2Entity.class); - - /** - * 解析所有好友信息 - *Function: userFriend2
- *Description:
- * - * @param content - * @return - * @author acexy@thankjava.com - * @date 2017年6月14日 下午2:33:31 - * @version 1.0 - */ - public static FriendsList userFriends2(String content) { - FriendsList friendsList = new FriendsList(); - JSONObject userFriends2Json; - try { - userFriends2Json = FastJson.toJSONObject(content); - JSONObject result = (JSONObject) userFriends2Json.get("result"); - MapFunction: onlineStatus
- *Description:
- * - * @param friendsList - * @param content - * @return - * @author acexy@thankjava.com - * @date 2017年6月14日 下午4:05:59 - * @version 1.0 - */ - public static FriendsList onlineStatus(FriendsList friendsList, String content) { - try { - MapFunction: getDiscusList
- *Description:
- * - * @param content - * @return - * @author acexy@thankjava.com - * @date 2017年6月14日 下午4:06:12 - * @version 1.0 - */ - public static DiscusList getDiscusList(String content) { - DiscusList discusList = new DiscusList(); - try { - JSONObject discusListJson = FastJson.toJSONObject(content); - JSONObject result = (JSONObject) discusListJson.get("result"); - - MapFunction: getGroupsList
- *Description:
- * - * @param content - * @return - * @author acexy@thankjava.com - * @date 2017年6月14日 下午4:08:47 - * @version 1.0 - */ - public static GroupsList getGroupsList(String content) { - GroupsList groupsList = new GroupsList(); - try { - JSONObject groupsListJson = FastJson.toJSONObject(content); - JSONObject result = (JSONObject) groupsListJson.get("result"); - - MapFunction: getSelfInfo
- *Description:
- * - * @param content - * @return - * @author acexy@thankjava.com - * @date 2017年6月14日 下午4:11:42 - * @version 1.0 - */ - public static DetailedInfo getSelfInfo(String content) { - try { - JSONObject discusListJson = FastJson.toJSONObject(content); - JSONObject result = (JSONObject) discusListJson.get("result"); - return FastJson.toObject(result.toJSONString(), DetailedInfo.class); - } catch (Exception e) { - logger.error("解析getSelfInfo返回数据失败", e); - } - return null; - } - - /** - * 消息拉取数据解析 - *Function: parseToPollMsg
- *Description:
- * - * @param content - * @return - * @author acexy@thankjava.com - * @date 2017年6月14日 下午4:21:38 - * @version 1.0 - */ - public static PollMsg pollMsg(String content) { - try { - JSONObject contentJson = FastJson.toJSONObject(content); - if (contentJson.getInteger("retcode") != 0) { - return null; - } - // 处理数据 - JSONArray array = (JSONArray) contentJson.get("result"); - JSONObject pollMsgJson = (JSONObject) array.get(0); - - - JSONObject valueJson = pollMsgJson.getJSONObject("value"); - - // 由于腾讯协议bug造成群消息&讨论组消息,会将自己发送的消息poll识别成别人的消息, - // 此处需要过滤 - if (Session.getSession().getUin() == valueJson.getLongValue("send_uin")) { - return null; - } - - JSONArray contentArray = valueJson.getJSONArray("content"); - - valueJson.remove("content"); - - PollMsg pollMsg = FastJson.toObject(array.get(0).toString(), PollMsg.class); - Value value = pollMsg.getValue(); - int contentSize = contentArray.size(); - Content contentMsg = new Content(); - value.setContent(contentMsg); - Font font = FastJson.toObject(contentArray.getJSONArray(0).get(1).toString(), Font.class); - contentMsg.setFont(font); - - Object[] objs = new Object[contentSize - 1]; - Object obj; - for (int index = 1; index < contentSize; index++) { - obj = contentArray.get(index); - if (JSONArray.class == obj.getClass()) { - objs[index - 1] = Integer.parseInt(((JSONArray) obj).get(1).toString()); - } else if (String.class == obj.getClass()) { - objs[index - 1] = obj.toString(); - } - } - contentMsg.setMsg(objs); - return pollMsg; - } catch (Exception e) { - return null; - } - } -} +package com.thankjava.wqq.util; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.thankjava.toolkit3d.core.fastjson.FastJson; +import com.thankjava.wqq.entity.Session; +import com.thankjava.wqq.entity.msg.Content; +import com.thankjava.wqq.entity.msg.Font; +import com.thankjava.wqq.entity.msg.PollMsg; +import com.thankjava.wqq.entity.msg.Value; +import com.thankjava.wqq.entity.wqq.*; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.HashMap; +import java.util.Map; + +/** + * 用于解析腾讯返回json格式的数据 + *Function: JSON2Entity
+ *Description:
+ * + * @author acexy@thankjava.com + * @version 1.0 + * @date 2017年6月14日 下午2:27:34 + */ +public class JSON2Entity { + + private static Logger logger = LoggerFactory.getLogger(JSON2Entity.class); + + /** + * 解析所有好友信息 + *Function: userFriend2
+ *Description:
+ * + * @param content + * @return + * @author acexy@thankjava.com + * @date 2017年6月14日 下午2:33:31 + * @version 1.0 + */ + public static FriendsList userFriends2(String content) { + FriendsList friendsList = new FriendsList(); + JSONObject userFriends2Json; + try { + userFriends2Json = FastJson.toJSONObject(content); + JSONObject result = (JSONObject) userFriends2Json.get("result"); + MapFunction: onlineStatus
+ *Description:
+ * + * @param friendsList + * @param content + * @return + * @author acexy@thankjava.com + * @date 2017年6月14日 下午4:05:59 + * @version 1.0 + */ + public static FriendsList onlineStatus(FriendsList friendsList, String content) { + try { + MapFunction: getDiscusList
+ *Description:
+ * + * @param content + * @return + * @author acexy@thankjava.com + * @date 2017年6月14日 下午4:06:12 + * @version 1.0 + */ + public static DiscusList getDiscusList(String content) { + DiscusList discusList = new DiscusList(); + try { + JSONObject discusListJson = FastJson.toJSONObject(content); + JSONObject result = (JSONObject) discusListJson.get("result"); + + MapFunction: getGroupsList
+ *Description:
+ * + * @param content + * @return + * @author acexy@thankjava.com + * @date 2017年6月14日 下午4:08:47 + * @version 1.0 + */ + public static GroupsList getGroupsList(String content) { + GroupsList groupsList = new GroupsList(); + try { + JSONObject groupsListJson = FastJson.toJSONObject(content); + JSONObject result = (JSONObject) groupsListJson.get("result"); + + MapFunction: getSelfInfo
+ *Description:
+ * + * @param content + * @return + * @author acexy@thankjava.com + * @date 2017年6月14日 下午4:11:42 + * @version 1.0 + */ + public static DetailedInfo getSelfInfo(String content) { + try { + JSONObject discusListJson = FastJson.toJSONObject(content); + JSONObject result = (JSONObject) discusListJson.get("result"); + return FastJson.toObject(result.toJSONString(), DetailedInfo.class); + } catch (Exception e) { + logger.error("解析getSelfInfo返回数据失败", e); + } + return null; + } + + /** + * 消息拉取数据解析 + *Function: parseToPollMsg
+ *Description:
+ * + * @param content + * @return + * @author acexy@thankjava.com + * @date 2017年6月14日 下午4:21:38 + * @version 1.0 + */ + public static PollMsg pollMsg(String content) { + try { + JSONObject contentJson = FastJson.toJSONObject(content); + if (contentJson.getInteger("retcode") != 0) { + return null; + } + // 处理数据 + JSONArray array = (JSONArray) contentJson.get("result"); + JSONObject pollMsgJson = (JSONObject) array.get(0); + + + JSONObject valueJson = pollMsgJson.getJSONObject("value"); + + // 由于腾讯协议bug造成群消息&讨论组消息,会将自己发送的消息poll识别成别人的消息, + // 此处需要过滤 + if (Session.getSession().getUin() == valueJson.getLongValue("send_uin")) { + return null; + } + + JSONArray contentArray = valueJson.getJSONArray("content"); + + valueJson.remove("content"); + + PollMsg pollMsg = FastJson.toObject(array.get(0).toString(), PollMsg.class); + Value value = pollMsg.getValue(); + int contentSize = contentArray.size(); + Content contentMsg = new Content(); + value.setContent(contentMsg); + Font font = FastJson.toObject(contentArray.getJSONArray(0).get(1).toString(), Font.class); + contentMsg.setFont(font); + + Object[] objs = new Object[contentSize - 1]; + Object obj; + for (int index = 1; index < contentSize; index++) { + obj = contentArray.get(index); + if (JSONArray.class == obj.getClass()) { + objs[index - 1] = Integer.parseInt(((JSONArray) obj).get(1).toString()); + } else if (String.class == obj.getClass()) { + objs[index - 1] = obj.toString(); + } + } + contentMsg.setMsg(objs); + return pollMsg; + } catch (Exception e) { + return null; + } + } +} diff --git a/src/main/java/com/thankjava/wqq/util/WqqEncryptor.java b/src/main/java/com/thankjava/wqq/util/WqqEncryptor.java index 50d5c19..ac480ae 100644 --- a/src/main/java/com/thankjava/wqq/util/WqqEncryptor.java +++ b/src/main/java/com/thankjava/wqq/util/WqqEncryptor.java @@ -1,14 +1,14 @@ package com.thankjava.wqq.util; -import javax.script.Invocable; -import javax.script.ScriptEngine; -import javax.script.ScriptEngineManager; - +import com.thankjava.toolkit.core.utils.SourceLoaderUtil; +import com.thankjava.wqq.core.action.LoginAction; import org.apache.commons.io.IOUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.thankjava.toolkit.resource.SourceLoader; -import com.thankjava.wqq.core.action.LoginAction; + +import javax.script.Invocable; +import javax.script.ScriptEngine; +import javax.script.ScriptEngineManager; public class WqqEncryptor { @@ -29,7 +29,7 @@ public class WqqEncryptor { public static String hash(String uin, String ptwebqq) { try { - String jsSource = IOUtils.toString(SourceLoader.getResourceAsInputStream("hash.js"), "utf-8"); + String jsSource = IOUtils.toString(SourceLoaderUtil.getResourceAsInputStream("hash.js"), "utf-8"); ScriptEngineManager scriptEMgr = new ScriptEngineManager(); ScriptEngine engine = scriptEMgr.getEngineByMimeType("application/javascript"); engine.eval(jsSource);