diff --git a/3.0.0.VERSION b/3.1.0.VERSION
similarity index 100%
rename from 3.0.0.VERSION
rename to 3.1.0.VERSION
diff --git a/README.md b/README.md
index 752aa22..2147d5c 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,7 @@
#说明:
此开源版本为基础功能版本,只有消息推送的基础功能!netty版本,和mina版本结构和功能完全一致,大家可以选择自己喜欢的或者合适的版本学习或者使用!
-#侣信专业版2.2.0版本发布
+#侣信专业版2.2.3版本发布
#[http://farsunset.com](http://farsunset.com)
diff --git a/cim_for_mina/cim-android-sdk/.classpath b/cim_for_mina/cim-android-sdk/.classpath
index 7e9f666..a46165e 100644
--- a/cim_for_mina/cim-android-sdk/.classpath
+++ b/cim_for_mina/cim-android-sdk/.classpath
@@ -3,8 +3,8 @@
-
+
diff --git a/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/CIMCacheManager.java b/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/CIMCacheManager.java
new file mode 100644
index 0000000..eae048b
--- /dev/null
+++ b/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/CIMCacheManager.java
@@ -0,0 +1,109 @@
+/**
+ * Copyright 2013-2033 Xia Jun(3979434@qq.com).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ***************************************************************************************
+ * *
+ * Website : http://www.farsunset.com *
+ * *
+ ***************************************************************************************
+ */
+package com.farsunset.cim.sdk.android;
+
+import android.content.ContentResolver;
+import android.content.ContentValues;
+import android.content.Context;
+import android.database.Cursor;
+import android.net.Uri;
+class CIMCacheManager {
+
+
+ public static final String CIM_CONFIG_INFO = "CIM_CONFIG_INFO";
+
+ public static final String KEY_ACCOUNT = "KEY_ACCOUNT";
+
+ public static final String KEY_MANUAL_STOP = "KEY_MANUAL_STOP";
+
+ public static final String KEY_CIM_DESTROYED = "KEY_CIM_DESTROYED";
+
+ public static final String KEY_CIM_SERVIER_HOST = "KEY_CIM_SERVIER_HOST";
+
+ public static final String KEY_CIM_SERVIER_PORT = "KEY_CIM_SERVIER_PORT";
+
+ public static final String KEY_CIM_CONNECTION_STATE = "KEY_CIM_CONNECTION_STATE";
+
+
+ public static void remove(Context context ,String key)
+ {
+ ContentResolver resolver = context.getContentResolver();
+ resolver.delete(Uri.parse(CIMCacheProvider.CONTENT_URI), key, null);
+ }
+
+
+ public static void putString(Context context ,String key,String value)
+ {
+
+ ContentResolver resolver = context.getContentResolver();
+ ContentValues values = new ContentValues();
+ values.put("value", value);
+ values.put("key", key);
+ resolver.insert(Uri.parse(CIMCacheProvider.CONTENT_URI), values);
+
+ }
+
+ public static String getString(Context context ,String key)
+ {
+ String value = null;
+ ContentResolver resolver = context.getContentResolver();
+ Cursor cursor = resolver.query(Uri.parse(CIMCacheProvider.CONTENT_URI), new String[]{key}, null,null,null);
+ if (cursor!=null && cursor.moveToFirst())
+ {
+ value = cursor.getString(0);
+ cursor.close();
+ }
+ closeQuietly(cursor);
+ return value;
+ }
+
+ private static void closeQuietly(Cursor cursor){
+ try{
+ if(cursor!=null)
+ cursor.close();
+ }catch(Exception e){}
+ }
+
+ public static void putBoolean(Context context,String key,boolean value)
+ {
+ putString(context,key,Boolean.toString(value));
+ }
+
+ public static boolean getBoolean(Context context,String key)
+ {
+ String value = getString(context,key);
+ return value == null?false:Boolean.parseBoolean(value);
+ }
+
+
+ public static void putInt(Context context,String key,int value)
+ {
+ putString(context,key, String.valueOf(value));
+ }
+
+ public static int getInt(Context context,String key)
+ {
+ String value = getString(context,key);
+ return value == null?0:Integer.parseInt(value);
+ }
+
+}
diff --git a/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/CIMCacheProvider.java b/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/CIMCacheProvider.java
new file mode 100644
index 0000000..3109416
--- /dev/null
+++ b/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/CIMCacheProvider.java
@@ -0,0 +1,74 @@
+/**
+ * Copyright 2013-2033 Xia Jun(3979434@qq.com).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ***************************************************************************************
+ * *
+ * Website : http://www.farsunset.com *
+ * *
+ ***************************************************************************************
+ */
+package com.farsunset.cim.sdk.android;
+
+import android.content.ContentProvider;
+import android.content.ContentValues;
+import android.content.Context;
+import android.database.Cursor;
+import android.database.MatrixCursor;
+import android.net.Uri;
+
+public class CIMCacheProvider extends ContentProvider {
+ public static final String CONTENT_URI="content://com.farsunset.cim.provider";
+ static final String MODEL_KEY = "PRIVATE_CIM_CONFIG";
+
+
+ @Override
+ public int delete(Uri arg0, String key, String[] arg2) {
+ getContext().getSharedPreferences(MODEL_KEY, Context.MODE_PRIVATE).edit().remove(key).apply();
+ return 0;
+ }
+
+ @Override
+ public String getType(Uri arg0) {
+ return null;
+ }
+
+ @Override
+ public Uri insert(Uri arg0, ContentValues values) {
+ String key = values.getAsString("key");
+ String value = values.getAsString("value");
+ getContext().getSharedPreferences(MODEL_KEY, Context.MODE_PRIVATE).edit().putString(key, value).apply();
+ return null;
+ }
+
+ @Override
+ public boolean onCreate() {
+ return true;
+ }
+
+ @Override
+ public Cursor query(Uri arg0, String[] arg1, String key, String[] arg3, String arg4) {
+ MatrixCursor cursor = new MatrixCursor(new String[]{"value"});
+ String value = getContext().getSharedPreferences(MODEL_KEY, Context.MODE_PRIVATE).getString(arg1[0], null);
+ cursor.addRow(new Object[]{value});
+ return cursor;
+ }
+
+ @Override
+ public int update(Uri arg0, ContentValues arg1, String arg2, String[] arg3) {
+ return 0;
+ }
+
+
+}
diff --git a/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/CIMCacheToolkit.java b/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/CIMCacheToolkit.java
deleted file mode 100644
index 4557dab..0000000
--- a/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/CIMCacheToolkit.java
+++ /dev/null
@@ -1,170 +0,0 @@
-/**
- * Copyright 2013-2023 Xia Jun(3979434@qq.com).
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- ***************************************************************************************
- * *
- * Website : http://www.farsunset.com *
- * *
- ***************************************************************************************
- */
-package com.farsunset.cim.sdk.android;
-
-import android.content.ContentValues;
-import android.content.Context;
-import android.database.Cursor;
-import android.database.sqlite.SQLiteDatabase;
-import android.database.sqlite.SQLiteOpenHelper;
-
-class CIMCacheToolkit extends SQLiteOpenHelper {
-
- private static final String DATABASE_NAME = "CIM_CONFIG_INFO.db";
- private static final int DATABASE_VERSION = 20160406;
- private static final String TABLE_NAME = "T_CIM_CONFIG";
- private static CIMCacheToolkit toolkit;
-
- private static final String TABLE_SQL = "CREATE TABLE IF NOT EXISTS "+TABLE_NAME+" (KEY VARCHAR(64) PRIMARY KEY,VALUE TEXT)";
-
- private static final String DELETE_SQL = "DELETE FROM "+TABLE_NAME+" WHERE KEY = ?";
-
- private static final String QUERY_SQL = "SELECT VALUE FROM "+TABLE_NAME+" WHERE KEY = ?";
-
- private SQLiteDatabase mSQLiteDatabase;
-
- public static final String CIM_CONFIG_INFO = "CIM_CONFIG_INFO";
-
- public static final String KEY_ACCOUNT = "KEY_ACCOUNT";
-
- public static final String KEY_MANUAL_STOP = "KEY_MANUAL_STOP";
-
- public static final String KEY_CIM_DESTROYED = "KEY_CIM_DESTROYED";
-
- public static final String KEY_CIM_SERVIER_HOST = "KEY_CIM_SERVIER_HOST";
-
- public static final String KEY_CIM_SERVIER_PORT = "KEY_CIM_SERVIER_PORT";
-
- public static final String KEY_CIM_CONNECTION_STATE = "KEY_CIM_CONNECTION_STATE";
-
-
- public synchronized static CIMCacheToolkit getInstance(Context context){
-
- if(toolkit==null){
- toolkit = new CIMCacheToolkit(context);
- }
-
- return toolkit;
- }
-
-
- public CIMCacheToolkit(Context context, String name, SQLiteDatabase.CursorFactory factory, int version) {
- super(context, name, factory, version);
- }
-
- public CIMCacheToolkit(Context context){
- this(context, DATABASE_NAME,null, DATABASE_VERSION);
- }
-
-
- public synchronized void remove(String key)
- {
- getSQLiteDatabase().execSQL(DELETE_SQL,new String[]{key});
- }
-
-
- public synchronized void putString(String key,String value)
- {
-
- ContentValues values = new ContentValues();
- values.put("VALUE", value);
- int result = getSQLiteDatabase().updateWithOnConflict(TABLE_NAME, values, "KEY=?",new String[]{key},SQLiteDatabase.CONFLICT_FAIL);
- if(result<=0){
-
- values.put("KEY", key);
- getSQLiteDatabase().insert(TABLE_NAME, null, values);
- }
-
- }
-
- public synchronized String getString(String key)
- {
- String value = null;
- Cursor cursor = getSQLiteDatabase().rawQuery(QUERY_SQL, new String[]{key});
- if (cursor!=null)
- {
- if(cursor.moveToFirst()){
- value = cursor.getString(0);
- }
-
- cursor.close();
- }
-
- return value;
- }
-
- public void putBoolean(String key,boolean value)
- {
- putString(key,Boolean.toString(value));
- }
-
- public boolean getBoolean(String key)
- {
- String value = getString(key);
- return value == null?false:Boolean.parseBoolean(value);
- }
-
-
- public void putInt(String key,int value)
- {
- putString(key, String.valueOf(value));
- }
-
- public int getInt(String key)
- {
- String value = getString(key);
- return value == null?0:Integer.parseInt(value);
- }
-
- @Override
- public void onCreate(SQLiteDatabase database) {
- database.execSQL(TABLE_SQL);
- }
-
-
- public static synchronized void destroy(){
- if (toolkit!=null){
- try{toolkit.mSQLiteDatabase.close();}catch(Exception e){}
- try{toolkit.close();}catch(Exception e){}
- }
-
- toolkit = null;
-
- }
-
-
- private SQLiteDatabase getSQLiteDatabase(){
- if(mSQLiteDatabase!=null){
- return mSQLiteDatabase;
- }else
- {
- mSQLiteDatabase = getWritableDatabase();
- }
- return mSQLiteDatabase;
- }
-
-
- @Override
- public void onUpgrade(SQLiteDatabase database, int oldVersion, int newVersion) {
-
- }
-}
diff --git a/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/CIMConnectorManager.java b/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/CIMConnectorManager.java
index 4bb71ed..6589742 100644
--- a/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/CIMConnectorManager.java
+++ b/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/CIMConnectorManager.java
@@ -1,5 +1,5 @@
/**
- * Copyright 2013-2023 Xia Jun(3979434@qq.com).
+ * Copyright 2013-2033 Xia Jun(3979434@qq.com).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,7 +20,6 @@
***************************************************************************************
*/
package com.farsunset.cim.sdk.android;
-import java.io.Serializable;
import java.net.InetSocketAddress;
import java.util.Map;
import java.util.Random;
@@ -44,8 +43,8 @@ import android.net.NetworkInfo;
import android.util.Log;
import com.farsunset.cim.sdk.android.constant.CIMConstant;
-import com.farsunset.cim.sdk.android.exception.SessionDisconnectedException;
-import com.farsunset.cim.sdk.android.exception.NetworkDisconnectedException;
+import com.farsunset.cim.sdk.android.exception.SessionClosedException;
+import com.farsunset.cim.sdk.android.exception.NetworkDisabledException;
import com.farsunset.cim.sdk.android.filter.ClientMessageCodecFactory;
import com.farsunset.cim.sdk.android.model.HeartbeatRequest;
import com.farsunset.cim.sdk.android.model.HeartbeatResponse;
@@ -66,7 +65,7 @@ class CIMConnectorManager extends IoHandlerAdapter implements KeepAliveMessageF
private final int WRITE_TIMEOUT = 10 * 1000;//秒
private final int READ_IDLE_TIME = 120;//秒
- private final int HEARBEAT_TIME_OUT = (READ_IDLE_TIME + 20) * 1000;// 收到服务端心跳请求超时时间 毫秒
+ private final int HEARBEAT_TIME_OUT = (READ_IDLE_TIME + 10) * 1000;// 收到服务端心跳请求超时时间 毫秒
private final String KEY_LAST_HEART_TIME = "KEY_LAST_HEART_TIME" ;
private NioSocketConnector connector;
@@ -117,7 +116,7 @@ class CIMConnectorManager extends IoHandlerAdapter implements KeepAliveMessageF
Log.i(TAG, "****************CIM正在连接服务器 "+host+":"+port+"......");
- CIMCacheToolkit.getInstance(context).putBoolean(CIMCacheToolkit.KEY_CIM_CONNECTION_STATE, false);
+ CIMCacheManager.putBoolean(context,CIMCacheManager.KEY_CIM_CONNECTION_STATE, false);
InetSocketAddress remoteSocketAddress = new InetSocketAddress(host, port);
connectFuture = connector.connect(remoteSocketAddress);
connectFuture.awaitUninterruptibly();
@@ -128,7 +127,7 @@ class CIMConnectorManager extends IoHandlerAdapter implements KeepAliveMessageF
Intent intent = new Intent();
intent.setAction(CIMConstant.IntentAction.ACTION_CONNECTION_FAILED);
- intent.putExtra(Exception.class.getName(), e);
+ intent.putExtra(Exception.class.getName(), e.getClass().getSimpleName());
intent.putExtra("interval", interval);
context.sendBroadcast(intent);
@@ -144,7 +143,7 @@ class CIMConnectorManager extends IoHandlerAdapter implements KeepAliveMessageF
Intent intent = new Intent();
intent.setAction(CIMConstant.IntentAction.ACTION_CONNECTION_FAILED);
- intent.putExtra(Exception.class.getName(), new NetworkDisconnectedException());
+ intent.putExtra(Exception.class.getName(),NetworkDisabledException.class.getSimpleName());
context.sendBroadcast(intent);
return;
@@ -163,7 +162,7 @@ class CIMConnectorManager extends IoHandlerAdapter implements KeepAliveMessageF
boolean isSuccessed = false;
- Throwable exception = new SessionDisconnectedException();
+ String exceptionName =SessionClosedException.class.getSimpleName();
IoSession session = getCurrentSession();
if(session!=null && session.isConnected())
@@ -172,18 +171,16 @@ class CIMConnectorManager extends IoHandlerAdapter implements KeepAliveMessageF
// 消息发送超时 5秒
wf.awaitUninterruptibly(WRITE_TIMEOUT);
isSuccessed = wf.isWritten();
-
- if(wf.getException() instanceof Serializable)
+ if(wf.getException() != null)
{
- exception = wf.getException();
+ exceptionName =wf.getException().getClass().getSimpleName();
}
-
}
if(!isSuccessed){
Intent intent = new Intent();
intent.setAction(CIMConstant.IntentAction.ACTION_SENT_FAILED);
- intent.putExtra(Exception.class.getName(),exception);
+ intent.putExtra(Exception.class.getName(),exceptionName);
intent.putExtra(SentBody.class.getName(), body);
context.sendBroadcast(intent);
}
@@ -200,9 +197,6 @@ class CIMConnectorManager extends IoHandlerAdapter implements KeepAliveMessageF
connector.dispose();
}
-
- CIMCacheToolkit.destroy();
-
manager = null;
}
@@ -286,11 +280,6 @@ class CIMConnectorManager extends IoHandlerAdapter implements KeepAliveMessageF
if(cause!=null && cause.getMessage()!=null){
Log.e(TAG, cause.getMessage());
}
-
- Intent intent = new Intent();
- intent.setAction(CIMConstant.IntentAction.ACTION_UNCAUGHT_EXCEPTION);
- intent.putExtra(Exception.class.getName(), cause);
- context.sendBroadcast(intent);
}
@Override
diff --git a/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/CIMEventBroadcastReceiver.java b/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/CIMEventBroadcastReceiver.java
index 596b8f2..8feddb0 100644
--- a/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/CIMEventBroadcastReceiver.java
+++ b/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/CIMEventBroadcastReceiver.java
@@ -1,5 +1,5 @@
/**
- * Copyright 2013-2023 Xia Jun(3979434@qq.com).
+ * Copyright 2013-2033 Xia Jun(3979434@qq.com).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,9 +22,8 @@
package com.farsunset.cim.sdk.android;
-
import com.farsunset.cim.sdk.android.constant.CIMConstant;
-import com.farsunset.cim.sdk.android.exception.SessionDisconnectedException;
+import com.farsunset.cim.sdk.android.exception.SessionClosedException;
import com.farsunset.cim.sdk.android.model.Message;
import com.farsunset.cim.sdk.android.model.ReplyBody;
import com.farsunset.cim.sdk.android.model.SentBody;
@@ -55,7 +54,6 @@ public abstract class CIMEventBroadcastReceiver extends BroadcastReceiver{
{
startPushService();
}
-
/*
* 设备网络状态变化事件
@@ -80,7 +78,8 @@ public abstract class CIMEventBroadcastReceiver extends BroadcastReceiver{
if(intent.getAction().equals(CIMConstant.IntentAction.ACTION_CONNECTION_FAILED))
{
long interval = intent.getLongExtra("interval", CIMConstant.RECONN_INTERVAL_TIME);
- onConnectionFailed((Exception) intent.getSerializableExtra(Exception.class.getName()),interval);
+ String exceptionName = intent.getStringExtra(Exception.class.getName());
+ onConnectionFailed(exceptionName,interval);
}
/*
@@ -114,9 +113,9 @@ public abstract class CIMEventBroadcastReceiver extends BroadcastReceiver{
*/
if(intent.getAction().equals(CIMConstant.IntentAction.ACTION_SENT_FAILED))
{
- Exception exception = (Exception) intent.getSerializableExtra(Exception.class.getName());
+ String exceptionName = intent.getStringExtra(Exception.class.getName());
SentBody sentBody = (SentBody)intent.getSerializableExtra(SentBody.class.getName());
- onSentFailed(exception,sentBody);
+ onSentFailed(exceptionName,sentBody);
}
/*
@@ -128,15 +127,7 @@ public abstract class CIMEventBroadcastReceiver extends BroadcastReceiver{
}
- /*
- * 获取cim数据传输异常事件
- */
- if(intent.getAction().equals(CIMConstant.IntentAction.ACTION_UNCAUGHT_EXCEPTION))
- {
- onUncaughtException((Exception)intent.getSerializableExtra(Exception.class.getName()));
- }
-
-
+
/*
* 重新连接,如果断开的话
*/
@@ -153,7 +144,7 @@ public abstract class CIMEventBroadcastReceiver extends BroadcastReceiver{
}
private void onInnerConnectionClosed(){
- CIMCacheToolkit.getInstance(context).putBoolean(CIMCacheToolkit.KEY_CIM_CONNECTION_STATE, false);
+ CIMCacheManager.putBoolean(context,CIMCacheManager.KEY_CIM_CONNECTION_STATE, false);
if(CIMConnectorManager.isNetworkConnected(context))
{
CIMPushManager.connect(context,0);
@@ -162,7 +153,7 @@ public abstract class CIMEventBroadcastReceiver extends BroadcastReceiver{
onConnectionClosed();
}
- private void onConnectionFailed(Exception e,long reinterval){
+ private void onConnectionFailed(String exceptionName,long reinterval){
if(CIMConnectorManager.isNetworkConnected(context))
{
@@ -173,14 +164,12 @@ public abstract class CIMEventBroadcastReceiver extends BroadcastReceiver{
}
private void onInnerConnectionSuccessed(){
- CIMCacheToolkit.getInstance(context).putBoolean(CIMCacheToolkit.KEY_CIM_CONNECTION_STATE, true);
+ CIMCacheManager.putBoolean(context,CIMCacheManager.KEY_CIM_CONNECTION_STATE, true);
boolean autoBind = CIMPushManager.autoBindAccount(context);
onConnectionSuccessed(autoBind);
}
- private void onUncaughtException(Throwable arg0) {}
-
private void onDevicesNetworkChanged(NetworkInfo info) {
if(info !=null)
@@ -202,13 +191,13 @@ public abstract class CIMEventBroadcastReceiver extends BroadcastReceiver{
private boolean isForceOfflineMessage(String action)
{
- return CIMConstant.MessageAction.ACTION_999.equals(action) || CIMConstant.MessageAction.ACTION_444.equals(action);
+ return CIMConstant.MessageAction.ACTION_999.equals(action);
}
- private void onSentFailed(Exception e, SentBody body){
+ private void onSentFailed(String exceptionName, SentBody body){
//与服务端端开链接,重新连接
- if(e instanceof SessionDisconnectedException)
+ if(SessionClosedException.class.getSimpleName().equals(exceptionName))
{
CIMPushManager.connect(context,0);
}else
diff --git a/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/CIMEventListener.java b/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/CIMEventListener.java
index 1bc8191..b936dc6 100644
--- a/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/CIMEventListener.java
+++ b/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/CIMEventListener.java
@@ -1,5 +1,5 @@
/**
- * Copyright 2013-2023 Xia Jun(3979434@qq.com).
+ * Copyright 2013-2033 Xia Jun(3979434@qq.com).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/CIMListenerManager.java b/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/CIMListenerManager.java
index 0008d0d..1826f00 100644
--- a/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/CIMListenerManager.java
+++ b/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/CIMListenerManager.java
@@ -1,5 +1,5 @@
/**
- * Copyright 2013-2023 Xia Jun(3979434@qq.com).
+ * Copyright 2013-2033 Xia Jun(3979434@qq.com).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/CIMPushManager.java b/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/CIMPushManager.java
index 6d27800..9bff670 100644
--- a/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/CIMPushManager.java
+++ b/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/CIMPushManager.java
@@ -1,5 +1,5 @@
/**
- * Copyright 2013-2023 Xia Jun(3979434@qq.com).
+ * Copyright 2013-2033 Xia Jun(3979434@qq.com).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -48,6 +48,7 @@ public class CIMPushManager {
static String KEY_SEND_BODY ="KEY_SEND_BODY";
+ static String KEY_CIM_CONNECTION_STATUS ="KEY_CIM_CONNECTION_STATUS";
/**
* 初始化,连接服务端,在程序启动页或者 在Application里调用
@@ -63,20 +64,20 @@ public class CIMPushManager {
private static void connect(Context context,String ip,int port,boolean autoBind,long delayedTime){
- CIMCacheToolkit.getInstance(context).putBoolean(CIMCacheToolkit.KEY_CIM_DESTROYED, false);
- CIMCacheToolkit.getInstance(context).putBoolean(CIMCacheToolkit.KEY_MANUAL_STOP, false);
+ CIMCacheManager.putBoolean(context,CIMCacheManager.KEY_CIM_DESTROYED, false);
+ CIMCacheManager.putBoolean(context,CIMCacheManager.KEY_MANUAL_STOP, false);
- CIMCacheToolkit.getInstance(context).putString( CIMCacheToolkit.KEY_CIM_SERVIER_HOST, ip);
- CIMCacheToolkit.getInstance(context).putInt( CIMCacheToolkit.KEY_CIM_SERVIER_PORT, port);
+ CIMCacheManager.putString(context, CIMCacheManager.KEY_CIM_SERVIER_HOST, ip);
+ CIMCacheManager.putInt(context, CIMCacheManager.KEY_CIM_SERVIER_PORT, port);
if(!autoBind)
{
- CIMCacheToolkit.getInstance(context).remove(CIMCacheToolkit.KEY_ACCOUNT);
+ CIMCacheManager.remove(context,CIMCacheManager.KEY_ACCOUNT);
}
Intent serviceIntent = new Intent(context, CIMPushService.class);
- serviceIntent.putExtra(CIMCacheToolkit.KEY_CIM_SERVIER_HOST, ip);
- serviceIntent.putExtra(CIMCacheToolkit.KEY_CIM_SERVIER_PORT, port);
+ serviceIntent.putExtra(CIMCacheManager.KEY_CIM_SERVIER_HOST, ip);
+ serviceIntent.putExtra(CIMCacheManager.KEY_CIM_SERVIER_PORT, port);
serviceIntent.putExtra(CIMPushService.KEY_DELAYED_TIME, delayedTime);
serviceIntent.setAction(ACTION_CREATE_CIM_CONNECTION);
context.startService(serviceIntent);
@@ -85,16 +86,16 @@ public class CIMPushManager {
protected static void connect(Context context,long delayedTime){
- boolean isManualStop = CIMCacheToolkit.getInstance(context).getBoolean(CIMCacheToolkit.KEY_MANUAL_STOP);
- boolean isManualDestory = CIMCacheToolkit.getInstance(context).getBoolean(CIMCacheToolkit.KEY_CIM_DESTROYED);
+ boolean isManualStop = CIMCacheManager.getBoolean(context,CIMCacheManager.KEY_MANUAL_STOP);
+ boolean isManualDestory = CIMCacheManager.getBoolean(context,CIMCacheManager.KEY_CIM_DESTROYED);
if(isManualStop || isManualDestory)
{
return ;
}
- String host = CIMCacheToolkit.getInstance(context).getString( CIMCacheToolkit.KEY_CIM_SERVIER_HOST);
- int port =CIMCacheToolkit.getInstance(context).getInt( CIMCacheToolkit.KEY_CIM_SERVIER_PORT);
+ String host = CIMCacheManager.getString(context, CIMCacheManager.KEY_CIM_SERVIER_HOST);
+ int port =CIMCacheManager.getInt(context, CIMCacheManager.KEY_CIM_SERVIER_PORT);
connect(context,host,port,true,delayedTime);
@@ -108,7 +109,7 @@ public class CIMPushManager {
public static void bindAccount(Context context,String account){
- boolean isManualDestory = CIMCacheToolkit.getInstance(context).getBoolean(CIMCacheToolkit.KEY_CIM_DESTROYED);
+ boolean isManualDestory = CIMCacheManager.getBoolean(context,CIMCacheManager.KEY_CIM_DESTROYED);
if(isManualDestory || account==null || account.trim().length()==0)
{
return ;
@@ -121,8 +122,8 @@ public class CIMPushManager {
private static void sendBindRequest(Context context, String account){
- CIMCacheToolkit.getInstance(context).putBoolean(CIMCacheToolkit.KEY_MANUAL_STOP, false);
- CIMCacheToolkit.getInstance(context).putString(CIMCacheToolkit.KEY_ACCOUNT, account);
+ CIMCacheManager.putBoolean(context,CIMCacheManager.KEY_MANUAL_STOP, false);
+ CIMCacheManager.putString(context,CIMCacheManager.KEY_ACCOUNT, account);
String imei = ((TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE)).getDeviceId();
imei += context.getPackageName();
@@ -140,8 +141,8 @@ public class CIMPushManager {
protected static boolean autoBindAccount(Context context){
- String account = CIMCacheToolkit.getInstance(context).getString(CIMCacheToolkit.KEY_ACCOUNT);
- boolean isManualDestory = CIMCacheToolkit.getInstance(context).getBoolean(CIMCacheToolkit.KEY_CIM_DESTROYED);
+ String account = CIMCacheManager.getString(context,CIMCacheManager.KEY_ACCOUNT);
+ boolean isManualDestory = CIMCacheManager.getBoolean(context,CIMCacheManager.KEY_CIM_DESTROYED);
if( account==null || account.trim().length()==0 || isManualDestory )
{
return false;
@@ -161,8 +162,8 @@ public class CIMPushManager {
*/
public static void sendRequest(Context context, SentBody body){
- boolean isManualStop = CIMCacheToolkit.getInstance(context).getBoolean(CIMCacheToolkit.KEY_MANUAL_STOP);
- boolean isManualDestory = CIMCacheToolkit.getInstance(context).getBoolean(CIMCacheToolkit.KEY_CIM_DESTROYED);
+ boolean isManualStop = CIMCacheManager.getBoolean(context,CIMCacheManager.KEY_MANUAL_STOP);
+ boolean isManualDestory = CIMCacheManager.getBoolean(context,CIMCacheManager.KEY_CIM_DESTROYED);
if(isManualStop || isManualDestory)
{
@@ -182,12 +183,12 @@ public class CIMPushManager {
*/
public static void stop(Context context){
- boolean isManualDestory = CIMCacheToolkit.getInstance(context).getBoolean(CIMCacheToolkit.KEY_CIM_DESTROYED);
+ boolean isManualDestory = CIMCacheManager.getBoolean(context,CIMCacheManager.KEY_CIM_DESTROYED);
if(isManualDestory){
return ;
}
- CIMCacheToolkit.getInstance(context).putBoolean(CIMCacheToolkit.KEY_MANUAL_STOP, true);
+ CIMCacheManager.putBoolean(context,CIMCacheManager.KEY_MANUAL_STOP, true);
Intent serviceIntent = new Intent(context, CIMPushService.class);
serviceIntent.setAction(ACTION_CLOSE_CIM_CONNECTION);
@@ -203,8 +204,8 @@ public class CIMPushManager {
public static void destroy(Context context){
- CIMCacheToolkit.getInstance(context).putBoolean(CIMCacheToolkit.KEY_CIM_DESTROYED, true);
- CIMCacheToolkit.getInstance(context).putString(CIMCacheToolkit.KEY_ACCOUNT, null);
+ CIMCacheManager.putBoolean(context,CIMCacheManager.KEY_CIM_DESTROYED, true);
+ CIMCacheManager.putString(context,CIMCacheManager.KEY_ACCOUNT, null);
Intent serviceIntent = new Intent(context, CIMPushService.class);
serviceIntent.setAction(ACTION_DESTORY);
@@ -219,7 +220,7 @@ public class CIMPushManager {
*/
public static void resume(Context context){
- boolean isManualDestory = CIMCacheToolkit.getInstance(context).getBoolean(CIMCacheToolkit.KEY_CIM_DESTROYED);
+ boolean isManualDestory = CIMCacheManager.getBoolean(context,CIMCacheManager.KEY_CIM_DESTROYED);
if(isManualDestory){
return ;
}
@@ -228,7 +229,7 @@ public class CIMPushManager {
}
public static boolean isConnected(Context context){
- return CIMCacheToolkit.getInstance(context).getBoolean(CIMCacheToolkit.KEY_CIM_CONNECTION_STATE);
+ return CIMCacheManager.getBoolean(context,CIMCacheManager.KEY_CIM_CONNECTION_STATE);
}
diff --git a/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/CIMPushService.java b/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/CIMPushService.java
index 9ae1cc7..09bdb87 100644
--- a/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/CIMPushService.java
+++ b/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/CIMPushService.java
@@ -1,5 +1,5 @@
/**
- * Copyright 2013-2023 Xia Jun(3979434@qq.com).
+ * Copyright 2013-2033 Xia Jun(3979434@qq.com).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -51,8 +51,8 @@ import com.farsunset.cim.sdk.android.model.SentBody;
connectionHandler.removeMessages(0);
- String host = message.getData().getString(CIMCacheToolkit.KEY_CIM_SERVIER_HOST);
- int port = message.getData().getInt(CIMCacheToolkit.KEY_CIM_SERVIER_PORT,0);
+ String host = message.getData().getString(CIMCacheManager.KEY_CIM_SERVIER_HOST);
+ int port = message.getData().getInt(CIMCacheManager.KEY_CIM_SERVIER_PORT,0);
manager.connect(host, port);
}
};
@@ -79,8 +79,8 @@ import com.farsunset.cim.sdk.android.model.SentBody;
}else
{
- String host = intent.getStringExtra(CIMCacheToolkit.KEY_CIM_SERVIER_HOST);
- int port = intent.getIntExtra(CIMCacheToolkit.KEY_CIM_SERVIER_PORT,0);
+ String host = intent.getStringExtra(CIMCacheManager.KEY_CIM_SERVIER_HOST);
+ int port = intent.getIntExtra(CIMCacheManager.KEY_CIM_SERVIER_PORT,0);
manager.connect(host,port);
}
}
@@ -105,7 +105,7 @@ import com.farsunset.cim.sdk.android.model.SentBody;
{
if(!manager.isConnected()){
- boolean isManualStop = CIMCacheToolkit.getInstance(this).getBoolean(CIMCacheToolkit.KEY_MANUAL_STOP);
+ boolean isManualStop = CIMCacheManager.getBoolean(getApplicationContext(),CIMCacheManager.KEY_MANUAL_STOP);
Log.w(TAG, "manager.isConnected() == false, isManualStop == " + isManualStop);
CIMPushManager.connect(this,0);
diff --git a/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/constant/CIMConstant.java b/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/constant/CIMConstant.java
index 8198c48..83dfc01 100644
--- a/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/constant/CIMConstant.java
+++ b/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/constant/CIMConstant.java
@@ -1,5 +1,5 @@
/**
- * Copyright 2013-2023 Xia Jun(3979434@qq.com).
+ * Copyright 2013-2033 Xia Jun(3979434@qq.com).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -74,8 +74,6 @@ public interface CIMConstant {
//被其他设备登录挤下线消息
String ACTION_999 ="999";
- //被系统禁用消息
- String ACTION_444 ="444";
}
@@ -105,9 +103,6 @@ public interface CIMConstant {
// 网络变化广播
String ACTION_NETWORK_CHANGED = "android.net.conn.CONNECTIVITY_CHANGE";
- // 未知异常
- String ACTION_UNCAUGHT_EXCEPTION = "com.farsunset.cim.UNCAUGHT_EXCEPTION";
-
//重试连接
String ACTION_CONNECTION_RECOVERY = "com.farsunset.cim.CONNECTION_RECOVERY";
}
diff --git a/cim_for_netty/cim-android-sdk/src/com/farsunset/cim/sdk/android/exception/NetworkDisconnectedException.java b/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/exception/NetworkDisabledException.java
similarity index 82%
rename from cim_for_netty/cim-android-sdk/src/com/farsunset/cim/sdk/android/exception/NetworkDisconnectedException.java
rename to cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/exception/NetworkDisabledException.java
index 151d878..b811f4e 100644
--- a/cim_for_netty/cim-android-sdk/src/com/farsunset/cim/sdk/android/exception/NetworkDisconnectedException.java
+++ b/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/exception/NetworkDisabledException.java
@@ -1,5 +1,5 @@
/**
- * Copyright 2013-2023 Xia Jun(3979434@qq.com).
+ * Copyright 2013-2033 Xia Jun(3979434@qq.com).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,16 +21,17 @@
*/
package com.farsunset.cim.sdk.android.exception;
+import java.io.Serializable;
-public class NetworkDisconnectedException extends Exception {
+public class NetworkDisabledException extends Exception implements Serializable {
private static final long serialVersionUID = 1L;
- public NetworkDisconnectedException() {
+ public NetworkDisabledException() {
super();
}
- public NetworkDisconnectedException(String s) {
+ public NetworkDisabledException(String s) {
super(s);
}
}
diff --git a/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/exception/SessionDisconnectedException.java b/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/exception/SessionClosedException.java
similarity index 83%
rename from cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/exception/SessionDisconnectedException.java
rename to cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/exception/SessionClosedException.java
index 149098d..b2440b7 100644
--- a/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/exception/SessionDisconnectedException.java
+++ b/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/exception/SessionClosedException.java
@@ -1,5 +1,5 @@
/**
- * Copyright 2013-2023 Xia Jun(3979434@qq.com).
+ * Copyright 2013-2033 Xia Jun(3979434@qq.com).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,16 +21,17 @@
*/
package com.farsunset.cim.sdk.android.exception;
+import java.io.Serializable;
-public class SessionDisconnectedException extends Exception {
+public class SessionClosedException extends Exception implements Serializable {
private static final long serialVersionUID = 1L;
- public SessionDisconnectedException() {
+ public SessionClosedException() {
super();
}
- public SessionDisconnectedException(String s) {
+ public SessionClosedException(String s) {
super(s);
}
}
diff --git a/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/filter/ClientMessageCodecFactory.java b/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/filter/ClientMessageCodecFactory.java
index 7aab39b..a123941 100644
--- a/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/filter/ClientMessageCodecFactory.java
+++ b/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/filter/ClientMessageCodecFactory.java
@@ -1,5 +1,5 @@
/**
- * Copyright 2013-2023 Xia Jun(3979434@qq.com).
+ * Copyright 2013-2033 Xia Jun(3979434@qq.com).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/filter/ClientMessageDecoder.java b/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/filter/ClientMessageDecoder.java
index 3da1a6c..ac1972c 100644
--- a/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/filter/ClientMessageDecoder.java
+++ b/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/filter/ClientMessageDecoder.java
@@ -1,5 +1,5 @@
/**
- * Copyright 2013-2023 Xia Jun(3979434@qq.com).
+ * Copyright 2013-2033 Xia Jun(3979434@qq.com).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/filter/ClientMessageEncoder.java b/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/filter/ClientMessageEncoder.java
index 8aa1894..4b958d2 100644
--- a/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/filter/ClientMessageEncoder.java
+++ b/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/filter/ClientMessageEncoder.java
@@ -1,5 +1,5 @@
/**
- * Copyright 2013-2023 Xia Jun(3979434@qq.com).
+ * Copyright 2013-2033 Xia Jun(3979434@qq.com).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/HeartbeatRequest.java b/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/HeartbeatRequest.java
index ece6cfa..671f74a 100644
--- a/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/HeartbeatRequest.java
+++ b/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/HeartbeatRequest.java
@@ -1,5 +1,5 @@
/**
- * Copyright 2013-2023 Xia Jun(3979434@qq.com).
+ * Copyright 2013-2033 Xia Jun(3979434@qq.com).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/HeartbeatResponse.java b/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/HeartbeatResponse.java
index 5250fb0..80fbbe2 100644
--- a/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/HeartbeatResponse.java
+++ b/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/HeartbeatResponse.java
@@ -1,5 +1,5 @@
/**
- * Copyright 2013-2023 Xia Jun(3979434@qq.com).
+ * Copyright 2013-2033 Xia Jun(3979434@qq.com).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/Message.java b/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/Message.java
index d8e46a7..5708fdf 100644
--- a/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/Message.java
+++ b/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/Message.java
@@ -1,5 +1,5 @@
/**
- * Copyright 2013-2023 Xia Jun(3979434@qq.com).
+ * Copyright 2013-2033 Xia Jun(3979434@qq.com).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/Protobufable.java b/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/Protobufable.java
index d504891..b7cbcb1 100644
--- a/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/Protobufable.java
+++ b/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/Protobufable.java
@@ -1,5 +1,5 @@
/**
- * Copyright 2013-2023 Xia Jun(3979434@qq.com).
+ * Copyright 2013-2033 Xia Jun(3979434@qq.com).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/ReplyBody.java b/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/ReplyBody.java
index 3a834ce..685a3a8 100644
--- a/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/ReplyBody.java
+++ b/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/ReplyBody.java
@@ -1,5 +1,5 @@
/**
- * Copyright 2013-2023 Xia Jun(3979434@qq.com).
+ * Copyright 2013-2033 Xia Jun(3979434@qq.com).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,9 +22,10 @@
package com.farsunset.cim.sdk.android.model;
import java.io.Serializable;
-import java.util.HashMap;
+import java.util.Hashtable;
import java.util.Map;
import java.util.Set;
+
/**
* 请求应答对象
*
@@ -49,19 +50,16 @@ public class ReplyBody implements Serializable {
*/
private String message;
- /**
- * 返回数据集合
- */
- private HashMap data;
-
private long timestamp;
- public ReplyBody()
- {
- data = new HashMap();
- timestamp = System.currentTimeMillis();
- }
+
+ /**
+ * 返回数据集合
+ */
+ private Hashtable data = new Hashtable();
+
+
public long getTimestamp() {
return timestamp;
}
@@ -81,9 +79,7 @@ public class ReplyBody implements Serializable {
}
public void put(String k, String v) {
- if(v!=null && k!=null){
- data.put(k, v);
- }
+ data.put(k, v);
}
public String get(String k) {
diff --git a/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/SentBody.java b/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/SentBody.java
index d73c444..e27aa31 100644
--- a/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/SentBody.java
+++ b/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/SentBody.java
@@ -1,5 +1,5 @@
/**
- * Copyright 2013-2023 Xia Jun(3979434@qq.com).
+ * Copyright 2013-2033 Xia Jun(3979434@qq.com).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,12 +22,12 @@
package com.farsunset.cim.sdk.android.model;
import java.io.Serializable;
-import java.util.HashMap;
-import java.util.Map;
+import java.util.Hashtable;
import java.util.Set;
import com.farsunset.cim.sdk.android.constant.CIMConstant;
import com.farsunset.cim.sdk.android.model.proto.SentBodyProto;
+
/**
* java |android 客户端请求结构
*
@@ -38,7 +38,7 @@ public class SentBody implements Serializable,Protobufable {
private String key;
- private HashMap data = new HashMap();;
+ private Hashtable data = new Hashtable();;
private long timestamp;
@@ -67,13 +67,12 @@ public class SentBody implements Serializable,Protobufable {
}
public void put(String k, String v) {
- if(v!=null && k!=null){
- data.put(k, v);
+ if(k == null || v == null){
+ return;
}
+ data.put(k, v);
}
- public void putAll(Map map) {
- data.putAll(map);
- }
+
public Set getKeySet() {
return data.keySet();
diff --git a/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/proto/MessageProto.java b/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/proto/MessageProto.java
index 39d9167..10f6db4 100644
--- a/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/proto/MessageProto.java
+++ b/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/proto/MessageProto.java
@@ -1,24 +1,6 @@
-/**
- * Copyright 2013-2023 Xia Jun(3979434@qq.com).
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- ***************************************************************************************
- * *
- * Website : http://www.farsunset.com *
- * *
- ***************************************************************************************
- */
+// Generated by the protocol buffer compiler. DO NOT EDIT!
+// source: Message.proto
+
package com.farsunset.cim.sdk.android.model.proto;
public final class MessageProto {
diff --git a/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/proto/ReplyBodyProto.java b/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/proto/ReplyBodyProto.java
index d370594..2cdd619 100644
--- a/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/proto/ReplyBodyProto.java
+++ b/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/proto/ReplyBodyProto.java
@@ -1,24 +1,6 @@
-/**
- * Copyright 2013-2023 Xia Jun(3979434@qq.com).
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- ***************************************************************************************
- * *
- * Website : http://www.farsunset.com *
- * *
- ***************************************************************************************
- */
+// Generated by the protocol buffer compiler. DO NOT EDIT!
+// source: ReplyBody.proto
+
package com.farsunset.cim.sdk.android.model.proto;
public final class ReplyBodyProto {
diff --git a/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/proto/SentBodyProto.java b/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/proto/SentBodyProto.java
index a781e8b..07fb5a7 100644
--- a/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/proto/SentBodyProto.java
+++ b/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/proto/SentBodyProto.java
@@ -1,24 +1,6 @@
-/**
- * Copyright 2013-2023 Xia Jun(3979434@qq.com).
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- ***************************************************************************************
- * *
- * Website : http://www.farsunset.com *
- * *
- ***************************************************************************************
- */
+// Generated by the protocol buffer compiler. DO NOT EDIT!
+// source: SentBody.proto
+
package com.farsunset.cim.sdk.android.model.proto;
public final class SentBodyProto {
diff --git a/cim_for_mina/cim-client-android/.idea/compiler.xml b/cim_for_mina/cim-client-android/.idea/compiler.xml
new file mode 100644
index 0000000..96cc43e
--- /dev/null
+++ b/cim_for_mina/cim-client-android/.idea/compiler.xml
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/cim_for_mina/cim-client-android/.idea/copyright/profiles_settings.xml b/cim_for_mina/cim-client-android/.idea/copyright/profiles_settings.xml
new file mode 100644
index 0000000..e7bedf3
--- /dev/null
+++ b/cim_for_mina/cim-client-android/.idea/copyright/profiles_settings.xml
@@ -0,0 +1,3 @@
+
+
+
\ No newline at end of file
diff --git a/cim_for_mina/cim-client-android/.idea/gradle.xml b/cim_for_mina/cim-client-android/.idea/gradle.xml
new file mode 100644
index 0000000..7ac24c7
--- /dev/null
+++ b/cim_for_mina/cim-client-android/.idea/gradle.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/cim_for_mina/cim-client-android/.idea/misc.xml b/cim_for_mina/cim-client-android/.idea/misc.xml
index 5e6e78a..5d19981 100644
--- a/cim_for_mina/cim-client-android/.idea/misc.xml
+++ b/cim_for_mina/cim-client-android/.idea/misc.xml
@@ -27,46 +27,6 @@
-
-
-
-
-
-
-
-
- Android
-
-
- Android > Lint > Correctness
-
-
- Android > Lint > Internationalization
-
-
- Android > Lint > Security
-
-
- CorrectnessLintAndroid
-
-
- Gradle
-
-
- LintAndroid
-
-
- Probable bugsGradle
-
-
-
-
- Android
-
-
-
-
-
@@ -83,23 +43,4 @@
-
-
-
-
-
-
-
- 1.8
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/cim_for_mina/cim-client-android/.idea/modules.xml b/cim_for_mina/cim-client-android/.idea/modules.xml
new file mode 100644
index 0000000..8b941a4
--- /dev/null
+++ b/cim_for_mina/cim-client-android/.idea/modules.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/cim_for_mina/cim-client-android/.idea/runConfigurations.xml b/cim_for_mina/cim-client-android/.idea/runConfigurations.xml
new file mode 100644
index 0000000..7f68460
--- /dev/null
+++ b/cim_for_mina/cim-client-android/.idea/runConfigurations.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/cim_for_mina/cim-client-android/app/build.gradle b/cim_for_mina/cim-client-android/app/build.gradle
index 1f042fa..7033f0f 100644
--- a/cim_for_mina/cim-client-android/app/build.gradle
+++ b/cim_for_mina/cim-client-android/app/build.gradle
@@ -7,8 +7,8 @@ android {
applicationId "com.farsunset.ichat.example"
minSdkVersion 14
targetSdkVersion 21
- versionCode 1
- versionName "1.0"
+ versionCode 31
+ versionName "3.1.0"
}
buildTypes {
release {
@@ -27,8 +27,8 @@ android {
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
- compile 'com.android.support:appcompat-v7:25.1.0'
- compile 'com.google.protobuf:protobuf-java:3.2.0'
+ compile 'com.android.support:appcompat-v7:25.3.1'
+ compile 'com.google.protobuf:protobuf-java:3.3.0'
compile 'org.apache.mina:mina-core:2.0.16'
compile 'org.slf4j:slf4j-api:1.7.24'
compile 'org.slf4j:slf4j-nop:1.7.24'
diff --git a/cim_for_mina/cim-client-android/app/libs/cim-server-sdk-3.0.jar b/cim_for_mina/cim-client-android/app/libs/cim-server-sdk-3.0.jar
deleted file mode 100644
index fb2f179..0000000
Binary files a/cim_for_mina/cim-client-android/app/libs/cim-server-sdk-3.0.jar and /dev/null differ
diff --git a/cim_for_mina/cim-client-android/app/libs/cim-server-sdk-3.1.jar b/cim_for_mina/cim-client-android/app/libs/cim-server-sdk-3.1.jar
new file mode 100644
index 0000000..da4e4f2
Binary files /dev/null and b/cim_for_mina/cim-client-android/app/libs/cim-server-sdk-3.1.jar differ
diff --git a/cim_for_mina/cim-client-android/app/src/main/AndroidManifest.xml b/cim_for_mina/cim-client-android/app/src/main/AndroidManifest.xml
index 913e67f..f69fcc3 100644
--- a/cim_for_mina/cim-client-android/app/src/main/AndroidManifest.xml
+++ b/cim_for_mina/cim-client-android/app/src/main/AndroidManifest.xml
@@ -1,8 +1,7 @@
+ >
@@ -47,8 +46,13 @@
android:launchMode="singleTop"
android:screenOrientation="portrait" />
-
-
+
+
+
+
diff --git a/cim_for_mina/cim-client-android/app/src/main/java/com/farsunset/ichat/example/app/Constant.java b/cim_for_mina/cim-client-android/app/src/main/java/com/farsunset/ichat/example/app/Constant.java
index 15b6ee8..3b3c32a 100644
--- a/cim_for_mina/cim-client-android/app/src/main/java/com/farsunset/ichat/example/app/Constant.java
+++ b/cim_for_mina/cim-client-android/app/src/main/java/com/farsunset/ichat/example/app/Constant.java
@@ -24,7 +24,7 @@ package com.farsunset.ichat.example.app;
public interface Constant {
//服务端IP地址
- public static final String CIM_SERVER_HOST = "172.168.11.28";
+ public static final String CIM_SERVER_HOST = "172.168.11.13";
//注意,这里的端口不是tomcat的端口,CIM端口在服务端spring-cim.xml中配置的,没改动就使用默认的23456
diff --git a/cim_for_mina/cim-client-android/build.gradle b/cim_for_mina/cim-client-android/build.gradle
index 74b2ab0..1ea4bd0 100644
--- a/cim_for_mina/cim-client-android/build.gradle
+++ b/cim_for_mina/cim-client-android/build.gradle
@@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
- classpath 'com.android.tools.build:gradle:2.2.3'
+ classpath 'com.android.tools.build:gradle:2.3.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
diff --git a/cim_for_mina/cim-server/.classpath b/cim_for_mina/cim-server/.classpath
index 0d97d57..262d7c8 100644
--- a/cim_for_mina/cim-server/.classpath
+++ b/cim_for_mina/cim-server/.classpath
@@ -2,11 +2,6 @@
-
-
-
-
-
@@ -14,5 +9,6 @@
+
diff --git a/cim_for_netty/cim-android-sdk/.classpath b/cim_for_netty/cim-android-sdk/.classpath
index 8b81c43..2af04b4 100644
--- a/cim_for_netty/cim-android-sdk/.classpath
+++ b/cim_for_netty/cim-android-sdk/.classpath
@@ -3,12 +3,12 @@
-
+
diff --git a/cim_for_netty/cim-android-sdk/src/com/farsunset/cim/sdk/android/CIMCacheManager.java b/cim_for_netty/cim-android-sdk/src/com/farsunset/cim/sdk/android/CIMCacheManager.java
new file mode 100644
index 0000000..eae048b
--- /dev/null
+++ b/cim_for_netty/cim-android-sdk/src/com/farsunset/cim/sdk/android/CIMCacheManager.java
@@ -0,0 +1,109 @@
+/**
+ * Copyright 2013-2033 Xia Jun(3979434@qq.com).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ***************************************************************************************
+ * *
+ * Website : http://www.farsunset.com *
+ * *
+ ***************************************************************************************
+ */
+package com.farsunset.cim.sdk.android;
+
+import android.content.ContentResolver;
+import android.content.ContentValues;
+import android.content.Context;
+import android.database.Cursor;
+import android.net.Uri;
+class CIMCacheManager {
+
+
+ public static final String CIM_CONFIG_INFO = "CIM_CONFIG_INFO";
+
+ public static final String KEY_ACCOUNT = "KEY_ACCOUNT";
+
+ public static final String KEY_MANUAL_STOP = "KEY_MANUAL_STOP";
+
+ public static final String KEY_CIM_DESTROYED = "KEY_CIM_DESTROYED";
+
+ public static final String KEY_CIM_SERVIER_HOST = "KEY_CIM_SERVIER_HOST";
+
+ public static final String KEY_CIM_SERVIER_PORT = "KEY_CIM_SERVIER_PORT";
+
+ public static final String KEY_CIM_CONNECTION_STATE = "KEY_CIM_CONNECTION_STATE";
+
+
+ public static void remove(Context context ,String key)
+ {
+ ContentResolver resolver = context.getContentResolver();
+ resolver.delete(Uri.parse(CIMCacheProvider.CONTENT_URI), key, null);
+ }
+
+
+ public static void putString(Context context ,String key,String value)
+ {
+
+ ContentResolver resolver = context.getContentResolver();
+ ContentValues values = new ContentValues();
+ values.put("value", value);
+ values.put("key", key);
+ resolver.insert(Uri.parse(CIMCacheProvider.CONTENT_URI), values);
+
+ }
+
+ public static String getString(Context context ,String key)
+ {
+ String value = null;
+ ContentResolver resolver = context.getContentResolver();
+ Cursor cursor = resolver.query(Uri.parse(CIMCacheProvider.CONTENT_URI), new String[]{key}, null,null,null);
+ if (cursor!=null && cursor.moveToFirst())
+ {
+ value = cursor.getString(0);
+ cursor.close();
+ }
+ closeQuietly(cursor);
+ return value;
+ }
+
+ private static void closeQuietly(Cursor cursor){
+ try{
+ if(cursor!=null)
+ cursor.close();
+ }catch(Exception e){}
+ }
+
+ public static void putBoolean(Context context,String key,boolean value)
+ {
+ putString(context,key,Boolean.toString(value));
+ }
+
+ public static boolean getBoolean(Context context,String key)
+ {
+ String value = getString(context,key);
+ return value == null?false:Boolean.parseBoolean(value);
+ }
+
+
+ public static void putInt(Context context,String key,int value)
+ {
+ putString(context,key, String.valueOf(value));
+ }
+
+ public static int getInt(Context context,String key)
+ {
+ String value = getString(context,key);
+ return value == null?0:Integer.parseInt(value);
+ }
+
+}
diff --git a/cim_for_netty/cim-android-sdk/src/com/farsunset/cim/sdk/android/CIMCacheProvider.java b/cim_for_netty/cim-android-sdk/src/com/farsunset/cim/sdk/android/CIMCacheProvider.java
new file mode 100644
index 0000000..3109416
--- /dev/null
+++ b/cim_for_netty/cim-android-sdk/src/com/farsunset/cim/sdk/android/CIMCacheProvider.java
@@ -0,0 +1,74 @@
+/**
+ * Copyright 2013-2033 Xia Jun(3979434@qq.com).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ***************************************************************************************
+ * *
+ * Website : http://www.farsunset.com *
+ * *
+ ***************************************************************************************
+ */
+package com.farsunset.cim.sdk.android;
+
+import android.content.ContentProvider;
+import android.content.ContentValues;
+import android.content.Context;
+import android.database.Cursor;
+import android.database.MatrixCursor;
+import android.net.Uri;
+
+public class CIMCacheProvider extends ContentProvider {
+ public static final String CONTENT_URI="content://com.farsunset.cim.provider";
+ static final String MODEL_KEY = "PRIVATE_CIM_CONFIG";
+
+
+ @Override
+ public int delete(Uri arg0, String key, String[] arg2) {
+ getContext().getSharedPreferences(MODEL_KEY, Context.MODE_PRIVATE).edit().remove(key).apply();
+ return 0;
+ }
+
+ @Override
+ public String getType(Uri arg0) {
+ return null;
+ }
+
+ @Override
+ public Uri insert(Uri arg0, ContentValues values) {
+ String key = values.getAsString("key");
+ String value = values.getAsString("value");
+ getContext().getSharedPreferences(MODEL_KEY, Context.MODE_PRIVATE).edit().putString(key, value).apply();
+ return null;
+ }
+
+ @Override
+ public boolean onCreate() {
+ return true;
+ }
+
+ @Override
+ public Cursor query(Uri arg0, String[] arg1, String key, String[] arg3, String arg4) {
+ MatrixCursor cursor = new MatrixCursor(new String[]{"value"});
+ String value = getContext().getSharedPreferences(MODEL_KEY, Context.MODE_PRIVATE).getString(arg1[0], null);
+ cursor.addRow(new Object[]{value});
+ return cursor;
+ }
+
+ @Override
+ public int update(Uri arg0, ContentValues arg1, String arg2, String[] arg3) {
+ return 0;
+ }
+
+
+}
diff --git a/cim_for_netty/cim-android-sdk/src/com/farsunset/cim/sdk/android/CIMConnectorManager.java b/cim_for_netty/cim-android-sdk/src/com/farsunset/cim/sdk/android/CIMConnectorManager.java
index 4272927..fb47578 100644
--- a/cim_for_netty/cim-android-sdk/src/com/farsunset/cim/sdk/android/CIMConnectorManager.java
+++ b/cim_for_netty/cim-android-sdk/src/com/farsunset/cim/sdk/android/CIMConnectorManager.java
@@ -45,10 +45,10 @@ import io.netty.handler.timeout.IdleStateEvent;
import io.netty.handler.timeout.IdleStateHandler;
import io.netty.util.AttributeKey;
import com.farsunset.cim.sdk.android.constant.CIMConstant;
-import com.farsunset.cim.sdk.android.exception.SessionDisconnectedException;
import com.farsunset.cim.sdk.android.filter.ClientMessageDecoder;
import com.farsunset.cim.sdk.android.filter.ClientMessageEncoder;
-import com.farsunset.cim.sdk.android.exception.NetworkDisconnectedException;
+import com.farsunset.cim.sdk.android.exception.NetworkDisabledException;
+import com.farsunset.cim.sdk.android.exception.SessionClosedException;
import com.farsunset.cim.sdk.android.model.HeartbeatRequest;
import com.farsunset.cim.sdk.android.model.HeartbeatResponse;
import com.farsunset.cim.sdk.android.model.Message;
@@ -129,7 +129,7 @@ class CIMConnectorManager extends SimpleChannelInboundHandler