Browse Source

调式im重连机制

SpringBoots 8 years ago
parent
commit
d7ce5dff43

+ 2 - 1
WeiChat/src/main/java/com/xzjmyk/pm/activity/xmpp/XReconnectionManager.java

@@ -44,6 +44,7 @@ public class XReconnectionManager extends AbstractConnectionListener {
 
 	public XReconnectionManager(Context context, XMPPConnection connection, boolean reconnectionAllowed, boolean isNetWorkActive) {
 		mContext = context;
+		LogUtil.d("Xmpp","XReconnectionManager 构造方法执行");
 		mConnection = connection;
 		mConnection.addConnectionListener(this);
 		isReconnectionAllowed = reconnectionAllowed;
@@ -192,7 +193,6 @@ public class XReconnectionManager extends AbstractConnectionListener {
 	private int syncCheckToken() {// 同步网络请求Token
 		if (CoreService.DEBUG) {
 			Log.d(CoreService.TAG, "开始重新登陆前的 Token 状态检查");
-			Log.d("wang", "开始重新登陆前的 Token 状态检查");
 			String requestUrl = MyApplication.getInstance().getConfig().USER_LOGIN_AUTO;
 			if (requestUrl == null) {
 				return 1;
@@ -232,6 +232,7 @@ public class XReconnectionManager extends AbstractConnectionListener {
 
 				StringBuilder sb = new StringBuilder();
 				sb.append("access_token=" + access_token + "&");
+			
 				String user = ((XMPPTCPConnection) mConnection).getDirectUser();
 				Log.d("wang", "user..." + user);
 				if (user == null) {

+ 4 - 1
WeiChat/src/main/java/com/xzjmyk/pm/activity/xmpp/XmppConnectionManager.java

@@ -11,6 +11,7 @@ import android.util.Log;
 
 import com.xzjmyk.pm.activity.MyApplication;
 import com.xzjmyk.pm.activity.ui.erp.util.CommonUtil;
+import com.xzjmyk.pm.activity.ui.erp.util.LogUtil;
 
 import org.apache.harmony.javax.security.sasl.SaslException;
 import org.jivesoftware.smack.AbstractConnectionListener;
@@ -118,7 +119,7 @@ public class XmppConnectionManager {
 			}
 			final boolean isConnected = isGprsOrWifiConnected();
 			if (mIsNetWorkActive != isConnected) {// 和之前的状态不同
-				Log.d("roamer", "网络状态改变了");
+				Log.d("roamer", "网络状态改变了 isLoginAllowed():"+isLoginAllowed());
 				mIsNetWorkActive = isConnected;
 				// 网络状态改变了
 				if (!mIsNetWorkActive) {// 由有网变为没网
@@ -327,9 +328,11 @@ public class XmppConnectionManager {
 				try {
 					if (!mConnection.isConnected()) {
 						((XMPPTCPConnection) mConnection).connectWithoutLogin();
+						LogUtil.d("Xmpp","connect WithoutLogin()");
 					}
 					if (mConnection.isConnected()) {
 						PingManager.getInstanceFor(mConnection).setPingInterval(60);
+						LogUtil.d("Xmpp","connect Login()");
 						mConnection.login(loginUserId, loginPassword, "youjob");
 //						presenceOnline();
 					}