2
0
mirror of https://gitee.com/hotlcc/wechat4j.git synced 2025-06-16 07:18:31 +08:00

提交代码

This commit is contained in:
hotlcc 2018-07-25 22:56:56 +08:00
parent be49394ca2
commit 62810d0993
2 changed files with 17 additions and 8 deletions

View File

@ -569,17 +569,21 @@ public class Wechat {
* 退出登录 * 退出登录
*/ */
public void logout(boolean clearAllLoginInfo) { public void logout(boolean clearAllLoginInfo) {
try { if (isOnline) {
isOnlineLock.lock(); try {
isOnlineLock.lock();
webWeixinApi.logout(httpClient, urlVersion, new BaseRequest(wxsid, skey, wxuin)); if (isOnline) {
isOnline = false; webWeixinApi.logout(httpClient, urlVersion, new BaseRequest(wxsid, skey, wxuin));
isOnline = false;
if (clearAllLoginInfo) { if (clearAllLoginInfo) {
clearAllLoginInfo(); clearAllLoginInfo();
}
}
} finally {
isOnlineLock.unlock();
} }
} finally {
isOnlineLock.unlock();
} }
} }

View File

@ -4,6 +4,7 @@ import com.hotlcc.wechat4j.api.WebWeixinApi;
import com.hotlcc.wechat4j.handler.ReceivedMsgHandler; import com.hotlcc.wechat4j.handler.ReceivedMsgHandler;
import com.hotlcc.wechat4j.model.ReceivedMsg; import com.hotlcc.wechat4j.model.ReceivedMsg;
import com.hotlcc.wechat4j.model.UserInfo; import com.hotlcc.wechat4j.model.UserInfo;
import com.sun.scenario.effect.GaussianShadow;
public class TestClass2 { public class TestClass2 {
public static void main(String[] args) { public static void main(String[] args) {
@ -22,5 +23,9 @@ public class TestClass2 {
} }
}); });
wechat.autoLogin(); wechat.autoLogin();
UserInfo userInfo = wechat.getContactByNickName(false, "Allen");
System.out.println(JSONObject.toJSONString(userInfo));
wechat.sendText("aaa", userInfo.getUserName());
wechat.logout();
} }
} }