mirror of
https://gitee.com/farsunset/cim.git
synced 2025-08-02 20:45:46 +08:00
1 修改消息断包时没有正确处理,导致消息接收不到的问题
2 修改多处细节问题
This commit is contained in:
parent
2c07c3a173
commit
3585cf4eb2
4
.gitignore
vendored
4
.gitignore
vendored
@ -6,5 +6,7 @@
|
|||||||
|
|
||||||
*.apk
|
*.apk
|
||||||
|
|
||||||
|
.fatjar
|
||||||
bin/
|
bin/
|
||||||
|
|
||||||
|
classes/
|
@ -2,8 +2,7 @@
|
|||||||
<classpath>
|
<classpath>
|
||||||
<classpathentry kind="src" path="src"/>
|
<classpathentry kind="src" path="src"/>
|
||||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||||
<classpathentry kind="lib" path="D:/cim-system/cim-server/WebRoot/WEB-INF/lib/log4j.jar"/>
|
|
||||||
<classpathentry kind="lib" path="/cim-server/WebRoot/WEB-INF/lib/mina-core-2.0.13.jar"/>
|
<classpathentry kind="lib" path="/cim-server/WebRoot/WEB-INF/lib/mina-core-2.0.13.jar"/>
|
||||||
<classpathentry kind="lib" path="D:/dev/Android-SDK-Windows/platforms/android-21/android.jar"/>
|
<classpathentry kind="lib" path="C:/dev/android-sdk-windows/platforms/android-22/android.jar"/>
|
||||||
<classpathentry kind="output" path="bin"/>
|
<classpathentry kind="output" path="bin"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* probject:cim-android-sdk
|
* probject:cim-android-sdk
|
||||||
* @version 2.0.0
|
* @version 2.1.0
|
||||||
*
|
*
|
||||||
* @author 3979434@qq.com
|
* @author 3979434@qq.com
|
||||||
*/
|
*/
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* probject:cim-android-sdk
|
* probject:cim-android-sdk
|
||||||
* @version 2.0.0
|
* @version 2.1.0
|
||||||
*
|
*
|
||||||
* @author 3979434@qq.com
|
* @author 3979434@qq.com
|
||||||
*/
|
*/
|
||||||
@ -40,7 +40,7 @@ import com.farsunset.cim.sdk.android.model.SentBody;
|
|||||||
*
|
*
|
||||||
* @author 3979434@qq.com
|
* @author 3979434@qq.com
|
||||||
*/
|
*/
|
||||||
class CIMConnectorManager {
|
class CIMConnectorManager extends IoHandlerAdapter implements KeepAliveMessageFactory{
|
||||||
|
|
||||||
final static String TAG = CIMConnectorManager.class.getSimpleName();
|
final static String TAG = CIMConnectorManager.class.getSimpleName();
|
||||||
private NioSocketConnector connector;
|
private NioSocketConnector connector;
|
||||||
@ -82,9 +82,9 @@ class CIMConnectorManager {
|
|||||||
public final static String ACTION_CONNECTION_RECOVERY = "com.farsunset.cim.CONNECTION_RECOVERY";
|
public final static String ACTION_CONNECTION_RECOVERY = "com.farsunset.cim.CONNECTION_RECOVERY";
|
||||||
|
|
||||||
private ExecutorService executor;
|
private ExecutorService executor;
|
||||||
private CIMConnectorManager(Context ctx) {
|
private CIMConnectorManager(Context ctx) {
|
||||||
context = ctx;
|
context = ctx;
|
||||||
executor = Executors.newFixedThreadPool(1);
|
executor = Executors.newCachedThreadPool();
|
||||||
|
|
||||||
connector = new NioSocketConnector();
|
connector = new NioSocketConnector();
|
||||||
connector.setConnectTimeoutMillis(10 * 1000);
|
connector.setConnectTimeoutMillis(10 * 1000);
|
||||||
@ -93,10 +93,10 @@ class CIMConnectorManager {
|
|||||||
connector.getSessionConfig().setReadBufferSize(2048);
|
connector.getSessionConfig().setReadBufferSize(2048);
|
||||||
connector.getFilterChain().addLast("codec", new ProtocolCodecFilter(new ClientMessageCodecFactory()));
|
connector.getFilterChain().addLast("codec", new ProtocolCodecFilter(new ClientMessageCodecFactory()));
|
||||||
|
|
||||||
KeepAliveFilter keepAliveaHandler = new KeepAliveFilter(new ClientKeepAliveFactoryImpl(), IdleStatus.BOTH_IDLE);
|
KeepAliveFilter keepAliveaHandler = new KeepAliveFilter(this, IdleStatus.BOTH_IDLE);
|
||||||
keepAliveaHandler.setForwardEvent(true);
|
keepAliveaHandler.setForwardEvent(true);
|
||||||
connector.getFilterChain().addLast("heartbeat", keepAliveaHandler);
|
connector.getFilterChain().addLast("heartbeat", keepAliveaHandler);
|
||||||
connector.setHandler(iohandler);
|
connector.setHandler(this);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -252,98 +252,94 @@ class CIMConnectorManager {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
IoHandlerAdapter iohandler = new IoHandlerAdapter() {
|
@Override
|
||||||
|
public void sessionCreated(IoSession session) throws Exception {
|
||||||
@Override
|
|
||||||
public void sessionCreated(IoSession session) throws Exception {
|
|
||||||
|
|
||||||
|
|
||||||
Log.i(TAG, "******************CIM连接服务器成功:"+session.getLocalAddress());
|
Log.i(TAG, "******************CIM连接服务器成功:"+session.getLocalAddress());
|
||||||
|
|
||||||
setLastHeartbeatTime(session);
|
setLastHeartbeatTime(session);
|
||||||
|
|
||||||
|
Intent intent = new Intent();
|
||||||
|
intent.setAction(ACTION_CONNECTION_SUCCESSED);
|
||||||
|
context.sendBroadcast(intent);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sessionOpened(IoSession session) throws Exception {
|
||||||
|
session.getConfig().setBothIdleTime(180);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sessionClosed(IoSession session) throws Exception {
|
||||||
|
|
||||||
|
Log.e(TAG, "******************CIM与服务器断开连接:"+session.getLocalAddress());
|
||||||
|
|
||||||
|
Intent intent = new Intent();
|
||||||
|
intent.setAction(ACTION_CONNECTION_CLOSED);
|
||||||
|
context.sendBroadcast(intent);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sessionIdle(IoSession session, IdleStatus status)throws Exception {
|
||||||
|
Log.d(TAG, "******************CIM与服务器连接空闲:"+session.getLocalAddress() + " isActive:" + session.isActive()+ " isConnected:" + session.isConnected());
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用于解决,wifi情况下。偶而路由器与服务器断开连接时,客户端并没及时收到关闭事件
|
||||||
|
* 导致这样的情况下当前连接无效也不会重连的问题
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
long lastHeartbeatTime = getLastHeartbeatTime(session);
|
||||||
|
if(System.currentTimeMillis() - lastHeartbeatTime >= HEARBEAT_TIME_OUT)
|
||||||
|
{
|
||||||
|
session.closeNow();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void exceptionCaught(IoSession session, Throwable cause)
|
||||||
|
throws Exception {
|
||||||
|
|
||||||
|
Intent intent = new Intent();
|
||||||
|
intent.setAction(ACTION_UNCAUGHT_EXCEPTION);
|
||||||
|
intent.putExtra("exception", cause);
|
||||||
|
context.sendBroadcast(intent);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void messageReceived(IoSession session, Object obj)
|
||||||
|
throws Exception {
|
||||||
|
|
||||||
|
if (obj instanceof Message) {
|
||||||
|
|
||||||
Intent intent = new Intent();
|
Intent intent = new Intent();
|
||||||
intent.setAction(ACTION_CONNECTION_SUCCESSED);
|
intent.setAction(ACTION_MESSAGE_RECEIVED);
|
||||||
|
intent.putExtra("message", (Message) obj);
|
||||||
context.sendBroadcast(intent);
|
context.sendBroadcast(intent);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
if (obj instanceof ReplyBody) {
|
||||||
|
|
||||||
@Override
|
|
||||||
public void sessionOpened(IoSession session) throws Exception {
|
|
||||||
session.getConfig().setBothIdleTime(180);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void sessionClosed(IoSession session) throws Exception {
|
|
||||||
|
|
||||||
Log.e(TAG, "******************CIM与服务器断开连接:"+session.getLocalAddress());
|
|
||||||
|
|
||||||
Intent intent = new Intent();
|
Intent intent = new Intent();
|
||||||
intent.setAction(ACTION_CONNECTION_CLOSED);
|
intent.setAction(ACTION_REPLY_RECEIVED);
|
||||||
|
intent.putExtra("replyBody", (ReplyBody) obj);
|
||||||
context.sendBroadcast(intent);
|
context.sendBroadcast(intent);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sessionIdle(IoSession session, IdleStatus status)throws Exception {
|
public void messageSent(IoSession session, Object message) throws Exception {
|
||||||
Log.d(TAG, "******************CIM与服务器连接空闲:"+session.getLocalAddress() + " isActive:" + session.isActive()+ " isConnected:" + session.isConnected());
|
if(message instanceof SentBody)
|
||||||
|
{
|
||||||
/**
|
|
||||||
* 用于解决,wifi情况下。偶而路由器与服务器断开连接时,客户端并没及时收到关闭事件
|
|
||||||
* 导致这样的情况下当前连接无效也不会重连的问题
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
long lastHeartbeatTime = getLastHeartbeatTime(session);
|
|
||||||
if(System.currentTimeMillis() - lastHeartbeatTime >= HEARBEAT_TIME_OUT)
|
|
||||||
{
|
|
||||||
session.closeNow();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void exceptionCaught(IoSession session, Throwable cause)
|
|
||||||
throws Exception {
|
|
||||||
|
|
||||||
Intent intent = new Intent();
|
Intent intent = new Intent();
|
||||||
intent.setAction(ACTION_UNCAUGHT_EXCEPTION);
|
intent.setAction(ACTION_SENT_SUCCESSED);
|
||||||
intent.putExtra("exception", cause);
|
intent.putExtra("sentBody", (SentBody) message);
|
||||||
context.sendBroadcast(intent);
|
context.sendBroadcast(intent);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public void messageReceived(IoSession session, Object obj)
|
|
||||||
throws Exception {
|
|
||||||
|
|
||||||
if (obj instanceof Message) {
|
|
||||||
|
|
||||||
Intent intent = new Intent();
|
|
||||||
intent.setAction(ACTION_MESSAGE_RECEIVED);
|
|
||||||
intent.putExtra("message", (Message) obj);
|
|
||||||
context.sendBroadcast(intent);
|
|
||||||
|
|
||||||
}
|
|
||||||
if (obj instanceof ReplyBody) {
|
|
||||||
|
|
||||||
|
|
||||||
Intent intent = new Intent();
|
|
||||||
intent.setAction(ACTION_REPLY_RECEIVED);
|
|
||||||
intent.putExtra("replyBody", (ReplyBody) obj);
|
|
||||||
context.sendBroadcast(intent);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void messageSent(IoSession session, Object message) throws Exception {
|
|
||||||
if(message instanceof SentBody)
|
|
||||||
{
|
|
||||||
Intent intent = new Intent();
|
|
||||||
intent.setAction(ACTION_SENT_SUCCESSED);
|
|
||||||
intent.putExtra("sentBody", (SentBody) message);
|
|
||||||
context.sendBroadcast(intent);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
private void setLastHeartbeatTime(IoSession session)
|
private void setLastHeartbeatTime(IoSession session)
|
||||||
{
|
{
|
||||||
@ -370,30 +366,27 @@ class CIMConnectorManager {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ClientKeepAliveFactoryImpl implements KeepAliveMessageFactory {
|
@Override
|
||||||
|
public Object getRequest(IoSession arg0) {
|
||||||
@Override
|
return null;
|
||||||
public Object getRequest(IoSession arg0) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getResponse(IoSession arg0, Object arg1) {
|
|
||||||
return CIMConstant.CMD_HEARTBEAT_RESPONSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isRequest(IoSession session, Object data) {
|
|
||||||
|
|
||||||
setLastHeartbeatTime(session);
|
|
||||||
|
|
||||||
return CIMConstant.CMD_HEARTBEAT_REQUEST.equalsIgnoreCase(data.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isResponse(IoSession arg0, Object arg1) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getResponse(IoSession arg0, Object arg1) {
|
||||||
|
return CIMConstant.CMD_HEARTBEAT_RESPONSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isRequest(IoSession session, Object data) {
|
||||||
|
|
||||||
|
setLastHeartbeatTime(session);
|
||||||
|
|
||||||
|
return CIMConstant.CMD_HEARTBEAT_REQUEST.equalsIgnoreCase(data.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isResponse(IoSession arg0, Object arg1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* probject:cim-android-sdk
|
* probject:cim-android-sdk
|
||||||
* @version 2.0.0
|
* @version 2.1.0
|
||||||
*
|
*
|
||||||
* @author 3979434@qq.com
|
* @author 3979434@qq.com
|
||||||
*/
|
*/
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* probject:cim-android-sdk
|
* probject:cim-android-sdk
|
||||||
* @version 2.0.0
|
* @version 2.1.0
|
||||||
*
|
*
|
||||||
* @author 3979434@qq.com
|
* @author 3979434@qq.com
|
||||||
*/
|
*/
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* probject:cim-android-sdk
|
* probject:cim-android-sdk
|
||||||
* @version 2.0.0
|
* @version 2.1.0
|
||||||
*
|
*
|
||||||
* @author 3979434@qq.com
|
* @author 3979434@qq.com
|
||||||
*/
|
*/
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* probject:cim-android-sdk
|
* probject:cim-android-sdk
|
||||||
* @version 2.0.0
|
* @version 2.1.0
|
||||||
*
|
*
|
||||||
* @author 3979434@qq.com
|
* @author 3979434@qq.com
|
||||||
*/
|
*/
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* probject:cim-android-sdk
|
* probject:cim-android-sdk
|
||||||
* @version 2.0.0
|
* @version 2.1.0
|
||||||
*
|
*
|
||||||
* @author 3979434@qq.com
|
* @author 3979434@qq.com
|
||||||
*/
|
*/
|
||||||
@ -11,6 +11,7 @@ import android.content.Intent;
|
|||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.os.PowerManager;
|
import android.os.PowerManager;
|
||||||
import android.os.PowerManager.WakeLock;
|
import android.os.PowerManager.WakeLock;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
import com.farsunset.cim.sdk.android.model.SentBody;
|
import com.farsunset.cim.sdk.android.model.SentBody;
|
||||||
|
|
||||||
@ -20,7 +21,7 @@ import com.farsunset.cim.sdk.android.model.SentBody;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class CIMPushService extends Service {
|
public class CIMPushService extends Service {
|
||||||
|
final static String TAG = CIMPushService.class.getSimpleName();
|
||||||
protected final static int DEF_CIM_PORT = 28888;
|
protected final static int DEF_CIM_PORT = 28888;
|
||||||
CIMConnectorManager manager;
|
CIMConnectorManager manager;
|
||||||
WakeLock wakeLock;
|
WakeLock wakeLock;
|
||||||
@ -67,12 +68,19 @@ import com.farsunset.cim.sdk.android.model.SentBody;
|
|||||||
android.os.Process.killProcess(android.os.Process.myPid());
|
android.os.Process.killProcess(android.os.Process.myPid());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(CIMPushManager.ACTION_ACTIVATE_PUSH_SERVICE.equals(action) && !manager.isConnected())
|
if(CIMPushManager.ACTION_ACTIVATE_PUSH_SERVICE.equals(action) )
|
||||||
{
|
{
|
||||||
|
if(!manager.isConnected()){
|
||||||
|
|
||||||
|
boolean isManualStop = CIMCacheToolkit.getInstance(this).getBoolean(CIMCacheToolkit.KEY_MANUAL_STOP);
|
||||||
|
Log.i(TAG, "CIM.isConnected() == false, isManualStop == " + isManualStop);
|
||||||
|
CIMPushManager.connect(this);
|
||||||
|
|
||||||
|
}else
|
||||||
|
{
|
||||||
|
Log.i(TAG, "CIM.isConnected() == true");
|
||||||
|
}
|
||||||
|
|
||||||
String host = CIMCacheToolkit.getInstance(this).getString(CIMCacheToolkit.KEY_CIM_SERVIER_HOST);
|
|
||||||
int port =CIMCacheToolkit.getInstance(this).getInt( CIMCacheToolkit.KEY_CIM_SERVIER_PORT);
|
|
||||||
manager.connect(host,port);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try{
|
try{
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* probject:cim-android-sdk
|
* probject:cim-android-sdk
|
||||||
* @version 2.0.0
|
* @version 2.1.0
|
||||||
*
|
*
|
||||||
* @author 3979434@qq.com
|
* @author 3979434@qq.com
|
||||||
*/
|
*/
|
||||||
@ -52,8 +52,6 @@ public interface CIMConstant {
|
|||||||
|
|
||||||
public static String CLIENT_BIND ="client_bind";
|
public static String CLIENT_BIND ="client_bind";
|
||||||
|
|
||||||
public static String CLIENT_LOGOUT ="client_logout";
|
|
||||||
|
|
||||||
public static String CLIENT_OFFLINE_MESSAGE ="client_get_offline_message";
|
public static String CLIENT_OFFLINE_MESSAGE ="client_get_offline_message";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* probject:cim-android-sdk
|
* probject:cim-android-sdk
|
||||||
* @version 2.0.0
|
* @version 2.1.0
|
||||||
*
|
*
|
||||||
* @author 3979434@qq.com
|
* @author 3979434@qq.com
|
||||||
*/
|
*/
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* probject:cim-android-sdk
|
* probject:cim-android-sdk
|
||||||
* @version 2.0.0
|
* @version 2.1.0
|
||||||
*
|
*
|
||||||
* @author 3979434@qq.com
|
* @author 3979434@qq.com
|
||||||
*/
|
*/
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* probject:cim-android-sdk
|
* probject:cim-android-sdk
|
||||||
* @version 2.0.0
|
* @version 2.1.0
|
||||||
*
|
*
|
||||||
* @author 3979434@qq.com
|
* @author 3979434@qq.com
|
||||||
*/
|
*/
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* probject:cim-android-sdk
|
* probject:cim-android-sdk
|
||||||
* @version 2.0.0
|
* @version 2.1.0
|
||||||
*
|
*
|
||||||
* @author 3979434@qq.com
|
* @author 3979434@qq.com
|
||||||
*/
|
*/
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* probject:cim-android-sdk
|
* probject:cim-android-sdk
|
||||||
* @version 2.0.0
|
* @version 2.1.0
|
||||||
*
|
*
|
||||||
* @author 3979434@qq.com
|
* @author 3979434@qq.com
|
||||||
*/
|
*/
|
||||||
@ -31,12 +31,13 @@ public class ClientMessageDecoder extends CumulativeProtocolDecoder {
|
|||||||
|
|
||||||
final static String TAG = ClientMessageDecoder.class.getSimpleName();
|
final static String TAG = ClientMessageDecoder.class.getSimpleName();
|
||||||
|
|
||||||
private IoBuffer buff = IoBuffer.allocate(320).setAutoExpand(true);
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean doDecode(IoSession iosession, IoBuffer iobuffer,
|
public boolean doDecode(IoSession iosession, IoBuffer iobuffer,ProtocolDecoderOutput out) throws Exception {
|
||||||
ProtocolDecoderOutput out) throws Exception {
|
|
||||||
boolean complete = false;
|
boolean complete = false;
|
||||||
|
IoBuffer tBuffer = IoBuffer.allocate(320).setAutoExpand(true);
|
||||||
|
iobuffer.mark();
|
||||||
|
|
||||||
while (iobuffer.hasRemaining()) {
|
while (iobuffer.hasRemaining()) {
|
||||||
byte b = iobuffer.get();
|
byte b = iobuffer.get();
|
||||||
@ -49,16 +50,16 @@ public class ClientMessageDecoder extends CumulativeProtocolDecoder {
|
|||||||
complete = true;
|
complete = true;
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
buff.put(b);
|
tBuffer.put(b);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (complete) {
|
if (complete) {
|
||||||
buff.flip();
|
tBuffer.flip();
|
||||||
byte[] bytes = new byte[buff.limit()];
|
byte[] bytes = new byte[tBuffer.limit()];
|
||||||
buff.get(bytes);
|
tBuffer.get(bytes);
|
||||||
String message = new String(bytes, CIMConstant.UTF8);
|
String message = new String(bytes, CIMConstant.UTF8);
|
||||||
buff.clear();
|
tBuffer.clear();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -68,6 +69,9 @@ public class ClientMessageDecoder extends CumulativeProtocolDecoder {
|
|||||||
{
|
{
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
}else
|
||||||
|
{
|
||||||
|
iobuffer.reset();//如果消息没有接收完整,对buffer进行重置,下次继续读取
|
||||||
}
|
}
|
||||||
|
|
||||||
return complete;
|
return complete;
|
||||||
@ -96,7 +100,7 @@ public class ClientMessageDecoder extends CumulativeProtocolDecoder {
|
|||||||
NodeList items = doc.getElementsByTagName("data").item(0).getChildNodes();
|
NodeList items = doc.getElementsByTagName("data").item(0).getChildNodes();
|
||||||
for (int i = 0; i < items.getLength(); i++) {
|
for (int i = 0; i < items.getLength(); i++) {
|
||||||
Node node = items.item(i);
|
Node node = items.item(i);
|
||||||
reply.getData().put(node.getNodeName(), node.getTextContent());
|
reply.put(node.getNodeName(), node.getTextContent());
|
||||||
}
|
}
|
||||||
return reply;
|
return reply;
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* probject:cim-android-sdk
|
* probject:cim-android-sdk
|
||||||
* @version 2.0.0
|
* @version 2.1.0
|
||||||
*
|
*
|
||||||
* @author 3979434@qq.com
|
* @author 3979434@qq.com
|
||||||
*/
|
*/
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* probject:cim-android-sdk
|
* probject:cim-android-sdk
|
||||||
* @version 2.0.0
|
* @version 2.1.0
|
||||||
*
|
*
|
||||||
* @author 3979434@qq.com
|
* @author 3979434@qq.com
|
||||||
*/
|
*/
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* probject:cim-android-sdk
|
* probject:cim-android-sdk
|
||||||
* @version 2.0.0
|
* @version 2.1.0
|
||||||
*
|
*
|
||||||
* @author 3979434@qq.com
|
* @author 3979434@qq.com
|
||||||
*/
|
*/
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* probject:cim-android-sdk
|
* probject:cim-android-sdk
|
||||||
* @version 2.0.0
|
* @version 2.1.0
|
||||||
*
|
*
|
||||||
* @author 3979434@qq.com
|
* @author 3979434@qq.com
|
||||||
*/
|
*/
|
||||||
|
@ -28,10 +28,14 @@ import com.farsunset.cim.sdk.server.model.SentBody;
|
|||||||
public class ServerMessageDecoder extends CumulativeProtocolDecoder {
|
public class ServerMessageDecoder extends CumulativeProtocolDecoder {
|
||||||
|
|
||||||
protected final Logger logger = Logger.getLogger(ServerMessageDecoder.class);
|
protected final Logger logger = Logger.getLogger(ServerMessageDecoder.class);
|
||||||
private IoBuffer buff = IoBuffer.allocate(320).setAutoExpand(true);
|
|
||||||
@Override
|
@Override
|
||||||
public boolean doDecode(IoSession iosession, IoBuffer iobuffer, ProtocolDecoderOutput out) throws Exception {
|
public boolean doDecode(IoSession iosession, IoBuffer iobuffer, ProtocolDecoderOutput out) throws Exception {
|
||||||
|
|
||||||
boolean complete = false;
|
boolean complete = false;
|
||||||
|
IoBuffer tBuffer = IoBuffer.allocate(320).setAutoExpand(true);
|
||||||
|
|
||||||
|
iobuffer.mark();
|
||||||
|
|
||||||
while (iobuffer.hasRemaining()) {
|
while (iobuffer.hasRemaining()) {
|
||||||
byte b = iobuffer.get();
|
byte b = iobuffer.get();
|
||||||
/**
|
/**
|
||||||
@ -48,19 +52,19 @@ public class ServerMessageDecoder extends CumulativeProtocolDecoder {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
buff.put(b);
|
tBuffer.put(b);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (complete) {
|
if (complete) {
|
||||||
buff.flip();
|
tBuffer.flip();
|
||||||
byte[] bytes = new byte[buff.limit()];
|
byte[] bytes = new byte[tBuffer.limit()];
|
||||||
buff.get(bytes);
|
tBuffer.get(bytes);
|
||||||
|
|
||||||
String message = new String(bytes, CIMConstant.UTF8);
|
String message = new String(bytes, CIMConstant.UTF8);
|
||||||
|
|
||||||
logger.debug(message);
|
logger.debug(message);
|
||||||
|
|
||||||
buff.clear();
|
tBuffer.clear();
|
||||||
try{
|
try{
|
||||||
|
|
||||||
Object body = getSentBody(message);
|
Object body = getSentBody(message);
|
||||||
@ -70,6 +74,9 @@ public class ServerMessageDecoder extends CumulativeProtocolDecoder {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
logger.warn(e.getMessage());
|
logger.warn(e.getMessage());
|
||||||
}
|
}
|
||||||
|
}else
|
||||||
|
{
|
||||||
|
iobuffer.reset();//如果消息没有接收完整,对buffer进行重置,下次继续读取
|
||||||
}
|
}
|
||||||
return complete;
|
return complete;
|
||||||
}
|
}
|
||||||
|
@ -81,20 +81,10 @@ public class CIMIoHandler extends IoHandlerAdapter {
|
|||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
public void sessionClosed(IoSession ios) throws Exception {
|
public void sessionClosed(IoSession ios) throws Exception {
|
||||||
|
logger.warn(ios.getRemoteAddress());
|
||||||
CIMSession cimSession =new CIMSession(ios);
|
CIMSession cimSession =new CIMSession(ios);
|
||||||
try{
|
CIMRequestHandler handler = handlers.get(CIMSESSION_CLOSED_HANDLER_KEY);
|
||||||
logger.warn("sessionClosed()... from "+cimSession.getRemoteAddress());
|
handler.process(cimSession, null);
|
||||||
CIMRequestHandler handler = handlers.get(CIMSESSION_CLOSED_HANDLER_KEY);
|
|
||||||
if(handler!=null && cimSession.containsAttribute(CIMConstant.SESSION_KEY))
|
|
||||||
{
|
|
||||||
handler.process(cimSession, null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch(Exception e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* probject:cim-server-sdk
|
* probject:cim-server-sdk
|
||||||
* @version 2.0.0
|
* @version 2.1.0
|
||||||
*
|
*
|
||||||
* @author 3979434@qq.com
|
* @author 3979434@qq.com
|
||||||
*/
|
*/
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
<classpathentry kind="con" path="melibrary.com.genuitec.eclipse.j2eedt.core.MYECLIPSE_JAVAEE_5_CONTAINER"/>
|
<classpathentry kind="con" path="melibrary.com.genuitec.eclipse.j2eedt.core.MYECLIPSE_JAVAEE_5_CONTAINER"/>
|
||||||
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
|
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
|
||||||
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
|
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
|
||||||
<classpathentry combineaccessrules="false" kind="src" path="/cim-server-sdk"/>
|
|
||||||
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/Spring.aop-3.0.2.jar"/>
|
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/Spring.aop-3.0.2.jar"/>
|
||||||
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/Spring.asm-3.0.2.RELEASE.jar"/>
|
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/Spring.asm-3.0.2.RELEASE.jar"/>
|
||||||
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/Spring.beans-3.0.2.RELEASE.jar"/>
|
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/Spring.beans-3.0.2.RELEASE.jar"/>
|
||||||
@ -20,6 +19,7 @@
|
|||||||
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/antlr-2.7.6.jar"/>
|
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/antlr-2.7.6.jar"/>
|
||||||
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/asm.jar"/>
|
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/asm.jar"/>
|
||||||
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/aspectjweaver.jar"/>
|
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/aspectjweaver.jar"/>
|
||||||
|
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/cim-server-sdk-2.1.jar"/>
|
||||||
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/commons-fileupload-1.2.1.jar"/>
|
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/commons-fileupload-1.2.1.jar"/>
|
||||||
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/commons-io-2.4.jar"/>
|
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/commons-io-2.4.jar"/>
|
||||||
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/commons-lang-2.3.jar"/>
|
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/commons-lang-2.3.jar"/>
|
||||||
@ -30,6 +30,7 @@
|
|||||||
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/httpcore-4.3.2.jar"/>
|
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/httpcore-4.3.2.jar"/>
|
||||||
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/jstl-1.2.jar"/>
|
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/jstl-1.2.jar"/>
|
||||||
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/log4j.jar"/>
|
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/log4j.jar"/>
|
||||||
|
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/mina-core-2.0.13.jar"/>
|
||||||
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/ognl-2.7.3.jar"/>
|
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/ognl-2.7.3.jar"/>
|
||||||
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/slf4j-api-1.7.5.jar"/>
|
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/slf4j-api-1.7.5.jar"/>
|
||||||
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/slf4j-nop-1.7.5.jar"/>
|
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/slf4j-nop-1.7.5.jar"/>
|
||||||
@ -37,6 +38,5 @@
|
|||||||
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/struts2-core-2.1.8.1.jar"/>
|
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/struts2-core-2.1.8.1.jar"/>
|
||||||
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/xstream-1.3.jar"/>
|
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/xstream-1.3.jar"/>
|
||||||
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/xwork-core-2.1.6.jar"/>
|
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/xwork-core-2.1.6.jar"/>
|
||||||
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/mina-core-2.0.13.jar"/>
|
|
||||||
<classpathentry kind="output" path="WebRoot/WEB-INF/classes"/>
|
<classpathentry kind="output" path="WebRoot/WEB-INF/classes"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
Binary file not shown.
@ -1,37 +0,0 @@
|
|||||||
/**
|
|
||||||
* probject:cim
|
|
||||||
* @version 2.0
|
|
||||||
*
|
|
||||||
* @author 3979434@qq.com
|
|
||||||
*/
|
|
||||||
package com.farsunset.cim.handler;
|
|
||||||
|
|
||||||
import com.farsunset.cim.sdk.server.constant.CIMConstant;
|
|
||||||
import com.farsunset.cim.sdk.server.handler.CIMRequestHandler;
|
|
||||||
import com.farsunset.cim.sdk.server.model.ReplyBody;
|
|
||||||
import com.farsunset.cim.sdk.server.model.SentBody;
|
|
||||||
import com.farsunset.cim.sdk.server.session.CIMSession;
|
|
||||||
import com.farsunset.cim.sdk.server.session.DefaultSessionManager;
|
|
||||||
import com.farsunset.cim.util.ContextHolder;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 退出连接实现
|
|
||||||
*/
|
|
||||||
public class LogoutHandler implements CIMRequestHandler {
|
|
||||||
|
|
||||||
public ReplyBody process(CIMSession ios, SentBody message) {
|
|
||||||
|
|
||||||
|
|
||||||
DefaultSessionManager sessionManager = ((DefaultSessionManager) ContextHolder.getBean("CIMSessionManager"));
|
|
||||||
|
|
||||||
String account =ios.getAttribute(CIMConstant.SESSION_KEY).toString();
|
|
||||||
ios.removeAttribute(CIMConstant.SESSION_KEY);
|
|
||||||
ios.closeNow();
|
|
||||||
sessionManager.remove(account);
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -26,15 +26,12 @@ public class SessionClosedHandler implements CIMRequestHandler {
|
|||||||
|
|
||||||
public ReplyBody process(CIMSession ios, SentBody message) {
|
public ReplyBody process(CIMSession ios, SentBody message) {
|
||||||
|
|
||||||
DefaultSessionManager sessionManager = ((DefaultSessionManager) ContextHolder.getBean("CIMSessionManager"));
|
DefaultSessionManager sessionManager = ((DefaultSessionManager) ContextHolder.getBean("CIMSessionManager"));
|
||||||
|
|
||||||
if(ios.getAttribute(CIMConstant.SESSION_KEY)==null)
|
String account =ios.getAttribute(CIMConstant.SESSION_KEY).toString();
|
||||||
{
|
ios.removeAttribute(CIMConstant.SESSION_KEY);
|
||||||
return null;
|
ios.closeNow();
|
||||||
}
|
sessionManager.remove(account);
|
||||||
|
|
||||||
String account = ios.getAttribute(CIMConstant.SESSION_KEY).toString();
|
|
||||||
sessionManager.remove(account);
|
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
log4j.rootLogger=debug,console, file
|
log4j.rootLogger=info,console, file
|
||||||
|
|
||||||
#----------console----------------
|
#----------console----------------
|
||||||
log4j.appender.console=org.apache.log4j.ConsoleAppender
|
log4j.appender.console=org.apache.log4j.ConsoleAppender
|
||||||
log4j.appender.console.layout=org.apache.log4j.PatternLayout
|
log4j.appender.console.layout=org.apache.log4j.PatternLayout
|
||||||
log4j.appender.console.Target=System.out
|
log4j.appender.console.Target=System.out
|
||||||
log4j.appender.console.layout.ConversionPattern=%C %p %d{yyyy-MM-dd HH:mm:ss}%n%m%n--------------------------------------------------------------------------------------------------------------------------%n
|
log4j.appender.console.layout.ConversionPattern=%C.%M() %p %d{yyyy-MM-dd HH:mm:ss}%n%m%n--------------------------------------------------------------------------------------------------------------------------%n
|
||||||
#----------file----------------
|
#----------file----------------
|
||||||
log4j.appender.file=org.apache.log4j.FileAppender
|
log4j.appender.file=org.apache.log4j.FileAppender
|
||||||
log4j.appender.file.File=cim.log
|
log4j.appender.file.File=cim.log
|
||||||
log4j.appender.file.layout=org.apache.log4j.PatternLayout
|
log4j.appender.file.layout=org.apache.log4j.PatternLayout
|
||||||
log4j.appender.file.layout.ConversionPattern=%C %p %d{yyyy-MM-dd HH\:mm\:ss} - %m%n
|
log4j.appender.file.layout.ConversionPattern=%C.%M() %p %d{yyyy-MM-dd HH:mm:ss}%n%m%n--------------------------------------------------------------------------------------------------------------------------%n
|
||||||
|
|
||||||
|
@ -21,9 +21,7 @@
|
|||||||
<entry key="client_bind">
|
<entry key="client_bind">
|
||||||
<bean class="com.farsunset.cim.handler.BindHandler" />
|
<bean class="com.farsunset.cim.handler.BindHandler" />
|
||||||
</entry>
|
</entry>
|
||||||
<entry key="client_logout">
|
|
||||||
<bean class="com.farsunset.cim.handler.LogoutHandler" />
|
|
||||||
</entry>
|
|
||||||
<entry key="client_cimsession_closed">
|
<entry key="client_cimsession_closed">
|
||||||
<bean class="com.farsunset.cim.handler.SessionClosedHandler"/>
|
<bean class="com.farsunset.cim.handler.SessionClosedHandler"/>
|
||||||
</entry>
|
</entry>
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<classpath>
|
<classpath>
|
||||||
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
|
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
|
||||||
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
|
|
||||||
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
|
|
||||||
<classpathentry kind="src" path="src"/>
|
<classpathentry kind="src" path="src"/>
|
||||||
<classpathentry kind="src" path="gen"/>
|
<classpathentry kind="src" path="gen"/>
|
||||||
|
<classpathentry kind="lib" path="libs/android-support-v4.jar"/>
|
||||||
|
<classpathentry kind="lib" path="libs/fastjson-1.1.47.android.jar"/>
|
||||||
|
<classpathentry kind="lib" path="libs/httpmime-4.1.1.jar"/>
|
||||||
|
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
|
||||||
|
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
|
||||||
<classpathentry kind="output" path="bin/classes"/>
|
<classpathentry kind="output" path="bin/classes"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="com.farsunset.ichat.example"
|
package="com.farsunset.ichat.example"
|
||||||
android:versionCode="2"
|
android:versionCode="3"
|
||||||
android:versionName="2.0.0" >
|
android:versionName="2.1.0" >
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||||
|
Binary file not shown.
BIN
cim_for_mina/client-mchat-android/libs/cim-android-sdk-2.1.jar
Normal file
BIN
cim_for_mina/client-mchat-android/libs/cim-android-sdk-2.1.jar
Normal file
Binary file not shown.
BIN
cim_for_mina/client-mchat-android/libs/mina-core-2.0.13.jar
Normal file
BIN
cim_for_mina/client-mchat-android/libs/mina-core-2.0.13.jar
Normal file
Binary file not shown.
BIN
cim_for_mina/client-mchat-android/libs/slf4j-api-1.7.5.jar
Normal file
BIN
cim_for_mina/client-mchat-android/libs/slf4j-api-1.7.5.jar
Normal file
Binary file not shown.
BIN
cim_for_mina/client-mchat-android/libs/slf4j-nop-1.7.5.jar
Normal file
BIN
cim_for_mina/client-mchat-android/libs/slf4j-nop-1.7.5.jar
Normal file
Binary file not shown.
@ -6,29 +6,14 @@
|
|||||||
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
|
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
|
||||||
|
|
||||||
-dontwarn
|
-dontwarn
|
||||||
-keep public class com.adview.** {*;}
|
-keep public class org.apache.mina.** {*;}
|
||||||
-keeppackagenames com.madhouse.android.ads
|
-keep public class com.farsunset.cim.sdk.android.model.** {*;}
|
||||||
-keepclassmembers class * {public *;}
|
|
||||||
-keep public class com.wqmobile.sdk.** {*;}
|
|
||||||
-keep public class * {public *;}
|
|
||||||
-keep public class com.adwo.adsdk.AdwoAdBrowserActivity
|
|
||||||
-keep public class com.wooboo.** {*;}
|
|
||||||
-keep public class cn.aduu.adsdk.**{*;}
|
|
||||||
-keep class net.youmi.android.** {*;}
|
|
||||||
-keep public class * extends android.app.Activity
|
-keep public class * extends android.app.Activity
|
||||||
-keep public class * extends android.app.Application
|
-keep public class * extends android.app.Application
|
||||||
-keep public class * extends android.app.Service
|
-keep public class * extends android.app.Service
|
||||||
-keep public class * extends android.content.BroadcastReceiver
|
-keep public class * extends android.content.BroadcastReceiver
|
||||||
-keep public class * extends android.content.ContentProvider
|
-keep public class * extends android.content.ContentProvider
|
||||||
-keep public class com.android.vending.licensing.ILicensingService
|
|
||||||
-keep public class MobWin.*
|
|
||||||
-keep public class MobWin.cnst.*
|
|
||||||
-keep class com.tencent.lbsapi.*
|
|
||||||
-keep class com.tencent.lbsapi.core.*
|
|
||||||
-keep class LBSAPIProtocol.*
|
|
||||||
-keep class com.tencent.lbsapi.core.QLBSJNI {
|
|
||||||
*;
|
|
||||||
}
|
|
||||||
-keepclasseswithmembernames class * {
|
-keepclasseswithmembernames class * {
|
||||||
native <methods>;
|
native <methods>;
|
||||||
}
|
}
|
||||||
|
@ -8,4 +8,4 @@
|
|||||||
# project structure.
|
# project structure.
|
||||||
|
|
||||||
# Project target.
|
# Project target.
|
||||||
target=android-19
|
target=android-22
|
||||||
|
@ -9,7 +9,7 @@ package com.farsunset.ichat.example.app;
|
|||||||
public interface Constant {
|
public interface Constant {
|
||||||
|
|
||||||
//服务端IP地址
|
//服务端IP地址
|
||||||
public static final String CIM_SERVER_HOST = "192.168.2.2";
|
public static final String CIM_SERVER_HOST = "192.168.191.1";
|
||||||
|
|
||||||
//服务端web地址
|
//服务端web地址
|
||||||
public static final String SERVER_URL = "http://"+CIM_SERVER_HOST+":8080/cim-server";
|
public static final String SERVER_URL = "http://"+CIM_SERVER_HOST+":8080/cim-server";
|
||||||
|
@ -2,11 +2,11 @@
|
|||||||
<classpath>
|
<classpath>
|
||||||
<classpathentry kind="src" path="src"/>
|
<classpathentry kind="src" path="src"/>
|
||||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||||
<classpathentry kind="lib" path="C:/dev/Android-SDK-Windows/platforms/android-19/android.jar"/>
|
|
||||||
<classpathentry kind="lib" path="/cim-server/WebRoot/WEB-INF/lib/netty-codec-4.1.0.CR7.jar"/>
|
<classpathentry kind="lib" path="/cim-server/WebRoot/WEB-INF/lib/netty-codec-4.1.0.CR7.jar"/>
|
||||||
<classpathentry kind="lib" path="/cim-server/WebRoot/WEB-INF/lib/netty-handler-4.1.0.CR7.jar"/>
|
<classpathentry kind="lib" path="/cim-server/WebRoot/WEB-INF/lib/netty-handler-4.1.0.CR7.jar"/>
|
||||||
<classpathentry kind="lib" path="/cim-server/WebRoot/WEB-INF/lib/netty-buffer-4.1.0.CR7.jar"/>
|
<classpathentry kind="lib" path="/cim-server/WebRoot/WEB-INF/lib/netty-buffer-4.1.0.CR7.jar"/>
|
||||||
<classpathentry kind="lib" path="/cim-server/WebRoot/WEB-INF/lib/netty-transport-4.1.0.CR7.jar"/>
|
<classpathentry kind="lib" path="/cim-server/WebRoot/WEB-INF/lib/netty-transport-4.1.0.CR7.jar"/>
|
||||||
<classpathentry kind="lib" path="/cim-server/WebRoot/WEB-INF/lib/netty-common-4.1.0.CR7.jar"/>
|
<classpathentry kind="lib" path="/cim-server/WebRoot/WEB-INF/lib/netty-common-4.1.0.CR7.jar"/>
|
||||||
|
<classpathentry kind="lib" path="C:/dev/android-sdk-windows/platforms/android-22/android.jar"/>
|
||||||
<classpathentry kind="output" path="bin"/>
|
<classpathentry kind="output" path="bin"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
BIN
cim_for_netty/cim-android-sdk/cim-android-sdk-2.1.jar
Normal file
BIN
cim_for_netty/cim-android-sdk/cim-android-sdk-2.1.jar
Normal file
Binary file not shown.
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* probject:cim-android-sdk
|
* probject:cim-android-sdk
|
||||||
* @version 2.0.0
|
* @version 2.1.0
|
||||||
*
|
*
|
||||||
* @author 3979434@qq.com
|
* @author 3979434@qq.com
|
||||||
*/
|
*/
|
||||||
|
@ -94,7 +94,7 @@ class CIMConnectorManager extends SimpleChannelInboundHandler<Object> {
|
|||||||
|
|
||||||
private CIMConnectorManager(Context ctx) {
|
private CIMConnectorManager(Context ctx) {
|
||||||
context = ctx;
|
context = ctx;
|
||||||
executor = Executors.newFixedThreadPool(3);
|
executor = Executors.newCachedThreadPool();
|
||||||
bootstrap = new Bootstrap();
|
bootstrap = new Bootstrap();
|
||||||
loopGroup = new NioEventLoopGroup();
|
loopGroup = new NioEventLoopGroup();
|
||||||
bootstrap.group(loopGroup);
|
bootstrap.group(loopGroup);
|
||||||
@ -104,7 +104,7 @@ class CIMConnectorManager extends SimpleChannelInboundHandler<Object> {
|
|||||||
@Override
|
@Override
|
||||||
public void initChannel(SocketChannel ch) throws Exception {
|
public void initChannel(SocketChannel ch) throws Exception {
|
||||||
ChannelPipeline pipeline = ch.pipeline();
|
ChannelPipeline pipeline = ch.pipeline();
|
||||||
pipeline.addLast(new ClientMessageDecoder(ClassResolvers.cacheDisabled(null)));
|
pipeline.addLast(new ClientMessageDecoder(ClassResolvers.cacheDisabled(CIMConnectorManager.class.getClassLoader())));
|
||||||
pipeline.addLast(new ClientMessageEncoder());
|
pipeline.addLast(new ClientMessageEncoder());
|
||||||
pipeline.addLast(new IdleStateHandler(READ_IDLE_TIME,0,0));
|
pipeline.addLast(new IdleStateHandler(READ_IDLE_TIME,0,0));
|
||||||
pipeline.addLast(CIMConnectorManager.this);
|
pipeline.addLast(CIMConnectorManager.this);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* probject:cim-android-sdk
|
* probject:cim-android-sdk
|
||||||
* @version 2.0.0
|
* @version 2.1.0
|
||||||
*
|
*
|
||||||
* @author 3979434@qq.com
|
* @author 3979434@qq.com
|
||||||
*/
|
*/
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* probject:cim-android-sdk
|
* probject:cim-android-sdk
|
||||||
* @version 2.0.0
|
* @version 2.1.0
|
||||||
*
|
*
|
||||||
* @author 3979434@qq.com
|
* @author 3979434@qq.com
|
||||||
*/
|
*/
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* probject:cim-android-sdk
|
* probject:cim-android-sdk
|
||||||
* @version 2.0.0
|
* @version 2.1.0
|
||||||
*
|
*
|
||||||
* @author 3979434@qq.com
|
* @author 3979434@qq.com
|
||||||
*/
|
*/
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* probject:cim-android-sdk
|
* probject:cim-android-sdk
|
||||||
* @version 2.0.0
|
* @version 2.1.0
|
||||||
*
|
*
|
||||||
* @author 3979434@qq.com
|
* @author 3979434@qq.com
|
||||||
*/
|
*/
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* probject:cim-android-sdk
|
* probject:cim-android-sdk
|
||||||
* @version 2.0.0
|
* @version 2.1.0
|
||||||
*
|
*
|
||||||
* @author 3979434@qq.com
|
* @author 3979434@qq.com
|
||||||
*/
|
*/
|
||||||
@ -11,6 +11,7 @@ import android.content.Intent;
|
|||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.os.PowerManager;
|
import android.os.PowerManager;
|
||||||
import android.os.PowerManager.WakeLock;
|
import android.os.PowerManager.WakeLock;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
import com.farsunset.cim.sdk.android.model.SentBody;
|
import com.farsunset.cim.sdk.android.model.SentBody;
|
||||||
|
|
||||||
@ -20,7 +21,7 @@ import com.farsunset.cim.sdk.android.model.SentBody;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class CIMPushService extends Service {
|
public class CIMPushService extends Service {
|
||||||
|
final static String TAG = CIMPushService.class.getSimpleName();
|
||||||
protected final static int DEF_CIM_PORT = 28888;
|
protected final static int DEF_CIM_PORT = 28888;
|
||||||
CIMConnectorManager manager;
|
CIMConnectorManager manager;
|
||||||
WakeLock wakeLock;
|
WakeLock wakeLock;
|
||||||
@ -67,14 +68,22 @@ import com.farsunset.cim.sdk.android.model.SentBody;
|
|||||||
android.os.Process.killProcess(android.os.Process.myPid());
|
android.os.Process.killProcess(android.os.Process.myPid());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(CIMPushManager.ACTION_ACTIVATE_PUSH_SERVICE.equals(action) && !manager.isConnected())
|
if(CIMPushManager.ACTION_ACTIVATE_PUSH_SERVICE.equals(action) )
|
||||||
{
|
{
|
||||||
|
if(!manager.isConnected()){
|
||||||
|
|
||||||
|
boolean isManualStop = CIMCacheToolkit.getInstance(this).getBoolean(CIMCacheToolkit.KEY_MANUAL_STOP);
|
||||||
|
Log.d(TAG, "CIM.isConnected() == false, isManualStop == " + isManualStop);
|
||||||
|
CIMPushManager.connect(this);
|
||||||
|
|
||||||
|
}else
|
||||||
|
{
|
||||||
|
Log.d(TAG, "CIM.isConnected() == true");
|
||||||
|
}
|
||||||
|
|
||||||
String host = CIMCacheToolkit.getInstance(this).getString(CIMCacheToolkit.KEY_CIM_SERVIER_HOST);
|
|
||||||
int port =CIMCacheToolkit.getInstance(this).getInt( CIMCacheToolkit.KEY_CIM_SERVIER_PORT);
|
|
||||||
manager.connect(host,port);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
try{
|
try{
|
||||||
if(!wakeLock.isHeld())
|
if(!wakeLock.isHeld())
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* probject:cim-android-sdk
|
* probject:cim-android-sdk
|
||||||
* @version 2.0.0
|
* @version 2.1.0
|
||||||
*
|
*
|
||||||
* @author 3979434@qq.com
|
* @author 3979434@qq.com
|
||||||
*/
|
*/
|
||||||
@ -52,7 +52,6 @@ public interface CIMConstant {
|
|||||||
|
|
||||||
public static String CLIENT_BIND ="client_bind";
|
public static String CLIENT_BIND ="client_bind";
|
||||||
|
|
||||||
public static String CLIENT_LOGOUT ="client_logout";
|
|
||||||
|
|
||||||
public static String CLIENT_OFFLINE_MESSAGE ="client_get_offline_message";
|
public static String CLIENT_OFFLINE_MESSAGE ="client_get_offline_message";
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* probject:cim-android-sdk
|
* probject:cim-android-sdk
|
||||||
* @version 2.0.0
|
* @version 2.1.0
|
||||||
*
|
*
|
||||||
* @author 3979434@qq.com
|
* @author 3979434@qq.com
|
||||||
*/
|
*/
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* probject:cim-android-sdk
|
* probject:cim-android-sdk
|
||||||
* @version 2.0.0
|
* @version 2.1.0
|
||||||
*
|
*
|
||||||
* @author 3979434@qq.com
|
* @author 3979434@qq.com
|
||||||
*/
|
*/
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* probject:cim-android-sdk
|
* probject:cim-android-sdk
|
||||||
* @version 2.0.0
|
* @version 2.1.0
|
||||||
*
|
*
|
||||||
* @author 3979434@qq.com
|
* @author 3979434@qq.com
|
||||||
*/
|
*/
|
||||||
|
@ -39,6 +39,8 @@ public class ClientMessageDecoder extends ObjectDecoder {
|
|||||||
public Object decode(ChannelHandlerContext arg0, ByteBuf buffer) throws Exception {
|
public Object decode(ChannelHandlerContext arg0, ByteBuf buffer) throws Exception {
|
||||||
|
|
||||||
int length = buffer.readableBytes();
|
int length = buffer.readableBytes();
|
||||||
|
buffer.markReaderIndex();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CIMConstant.MESSAGE_SEPARATE 为消息界限
|
* CIMConstant.MESSAGE_SEPARATE 为消息界限
|
||||||
* 当一次收到多个消息时,以此分隔解析多个消息
|
* 当一次收到多个消息时,以此分隔解析多个消息
|
||||||
@ -59,6 +61,7 @@ public class ClientMessageDecoder extends ObjectDecoder {
|
|||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
buffer.resetReaderIndex();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* probject:cim-android-sdk
|
* probject:cim-android-sdk
|
||||||
* @version 2.0.0
|
* @version 2.1.0
|
||||||
*
|
*
|
||||||
* @author 3979434@qq.com
|
* @author 3979434@qq.com
|
||||||
*/
|
*/
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* probject:cim-android-sdk
|
* probject:cim-android-sdk
|
||||||
* @version 2.0.0
|
* @version 2.1.0
|
||||||
*
|
*
|
||||||
* @author 3979434@qq.com
|
* @author 3979434@qq.com
|
||||||
*/
|
*/
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* probject:cim-android-sdk
|
* probject:cim-android-sdk
|
||||||
* @version 2.0.0
|
* @version 2.1.0
|
||||||
*
|
*
|
||||||
* @author 3979434@qq.com
|
* @author 3979434@qq.com
|
||||||
*/
|
*/
|
||||||
|
@ -2,11 +2,11 @@
|
|||||||
<classpath>
|
<classpath>
|
||||||
<classpathentry kind="src" path="src"/>
|
<classpathentry kind="src" path="src"/>
|
||||||
<classpathentry kind="lib" path="/cim-server/WebRoot/WEB-INF/lib/log4j.jar"/>
|
<classpathentry kind="lib" path="/cim-server/WebRoot/WEB-INF/lib/log4j.jar"/>
|
||||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jdk1.7.0_80"/>
|
|
||||||
<classpathentry kind="lib" path="/cim-server/WebRoot/WEB-INF/lib/netty-buffer-4.1.0.CR7.jar"/>
|
<classpathentry kind="lib" path="/cim-server/WebRoot/WEB-INF/lib/netty-buffer-4.1.0.CR7.jar"/>
|
||||||
<classpathentry kind="lib" path="/cim-server/WebRoot/WEB-INF/lib/netty-codec-4.1.0.CR7.jar"/>
|
<classpathentry kind="lib" path="/cim-server/WebRoot/WEB-INF/lib/netty-codec-4.1.0.CR7.jar"/>
|
||||||
<classpathentry kind="lib" path="/cim-server/WebRoot/WEB-INF/lib/netty-common-4.1.0.CR7.jar"/>
|
<classpathentry kind="lib" path="/cim-server/WebRoot/WEB-INF/lib/netty-common-4.1.0.CR7.jar"/>
|
||||||
<classpathentry kind="lib" path="/cim-server/WebRoot/WEB-INF/lib/netty-handler-4.1.0.CR7.jar"/>
|
<classpathentry kind="lib" path="/cim-server/WebRoot/WEB-INF/lib/netty-handler-4.1.0.CR7.jar"/>
|
||||||
<classpathentry kind="lib" path="/cim-server/WebRoot/WEB-INF/lib/netty-transport-4.1.0.CR7.jar"/>
|
<classpathentry kind="lib" path="/cim-server/WebRoot/WEB-INF/lib/netty-transport-4.1.0.CR7.jar"/>
|
||||||
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||||
<classpathentry kind="output" path="bin"/>
|
<classpathentry kind="output" path="bin"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
@ -35,7 +35,7 @@ public class ServerMessageDecoder extends ObjectDecoder {
|
|||||||
|
|
||||||
|
|
||||||
int length = buffer.readableBytes();
|
int length = buffer.readableBytes();
|
||||||
|
buffer.markReaderIndex();
|
||||||
/**
|
/**
|
||||||
* CIMConstant.MESSAGE_SEPARATE 为消息界限
|
* CIMConstant.MESSAGE_SEPARATE 为消息界限
|
||||||
* 当一次收到多个消息时,以此分隔解析多个消息
|
* 当一次收到多个消息时,以此分隔解析多个消息
|
||||||
@ -81,6 +81,8 @@ public class ServerMessageDecoder extends ObjectDecoder {
|
|||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
buffer.resetReaderIndex();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ public class CIMNioSocketAcceptor extends SimpleChannelInboundHandler<SentBody>{
|
|||||||
public void initChannel(SocketChannel ch) throws Exception {
|
public void initChannel(SocketChannel ch) throws Exception {
|
||||||
ChannelPipeline pipeline = ch.pipeline();
|
ChannelPipeline pipeline = ch.pipeline();
|
||||||
|
|
||||||
pipeline.addLast(new ServerMessageDecoder(ClassResolvers.cacheDisabled(null)));
|
pipeline.addLast(new ServerMessageDecoder(ClassResolvers.cacheDisabled(CIMNioSocketAcceptor.class.getClassLoader())));
|
||||||
pipeline.addLast(new ServerMessageEncoder());
|
pipeline.addLast(new ServerMessageEncoder());
|
||||||
pipeline.addLast(new IdleStateHandler(READ_IDLE_TIME,WRITE_IDLE_TIME,0));
|
pipeline.addLast(new IdleStateHandler(READ_IDLE_TIME,WRITE_IDLE_TIME,0));
|
||||||
pipeline.addLast(CIMNioSocketAcceptor.this);
|
pipeline.addLast(CIMNioSocketAcceptor.this);
|
||||||
@ -93,10 +93,8 @@ public class CIMNioSocketAcceptor extends SimpleChannelInboundHandler<SentBody>{
|
|||||||
*/
|
*/
|
||||||
public void exceptionCaught( ChannelHandlerContext ctx, Throwable cause)
|
public void exceptionCaught( ChannelHandlerContext ctx, Throwable cause)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
logger.error("exceptionCaught()... from "+ctx.channel().remoteAddress());
|
logger.error(ctx.channel().remoteAddress());
|
||||||
ctx.channel().close();
|
|
||||||
CIMRequestHandler handler = handlers.get(CIMConstant.RequestKey.KEY_CLIENT_CIMSESSION_CLOSED);
|
|
||||||
handler.process(new CIMSession(ctx.channel()), null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -163,7 +161,9 @@ public class CIMNioSocketAcceptor extends SimpleChannelInboundHandler<SentBody>{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
|
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
|
||||||
logger.debug("channelInactive-----------"+ctx.channel().remoteAddress());
|
logger.warn(ctx.channel().remoteAddress());
|
||||||
|
CIMRequestHandler handler = handlers.get(CIMConstant.RequestKey.KEY_CLIENT_CIMSESSION_CLOSED);
|
||||||
|
handler.process(new CIMSession(ctx.channel()), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* probject:cim-server-sdk
|
* probject:cim-server-sdk
|
||||||
* @version 2.0.0
|
* @version 2.1.0
|
||||||
*
|
*
|
||||||
* @author 3979434@qq.com
|
* @author 3979434@qq.com
|
||||||
*/
|
*/
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
<classpathentry kind="con" path="melibrary.com.genuitec.eclipse.j2eedt.core.MYECLIPSE_JAVAEE_5_CONTAINER"/>
|
<classpathentry kind="con" path="melibrary.com.genuitec.eclipse.j2eedt.core.MYECLIPSE_JAVAEE_5_CONTAINER"/>
|
||||||
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
|
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
|
||||||
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
|
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
|
||||||
<classpathentry combineaccessrules="false" kind="src" path="/cim-server-sdk"/>
|
|
||||||
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/Spring.aop-3.0.2.jar"/>
|
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/Spring.aop-3.0.2.jar"/>
|
||||||
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/Spring.asm-3.0.2.RELEASE.jar"/>
|
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/Spring.asm-3.0.2.RELEASE.jar"/>
|
||||||
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/Spring.beans-3.0.2.RELEASE.jar"/>
|
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/Spring.beans-3.0.2.RELEASE.jar"/>
|
||||||
@ -22,6 +21,7 @@
|
|||||||
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/aspectjweaver.jar"/>
|
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/aspectjweaver.jar"/>
|
||||||
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/commons-fileupload-1.2.1.jar"/>
|
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/commons-fileupload-1.2.1.jar"/>
|
||||||
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/commons-io-2.4.jar"/>
|
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/commons-io-2.4.jar"/>
|
||||||
|
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/commons-lang-2.3.jar"/>
|
||||||
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/commons-logging-1.0.4.jar"/>
|
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/commons-logging-1.0.4.jar"/>
|
||||||
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/freemarker-2.3.15.jar"/>
|
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/freemarker-2.3.15.jar"/>
|
||||||
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/gson-2.1.jar"/>
|
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/gson-2.1.jar"/>
|
||||||
@ -29,14 +29,6 @@
|
|||||||
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/httpcore-4.3.2.jar"/>
|
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/httpcore-4.3.2.jar"/>
|
||||||
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/jstl-1.2.jar"/>
|
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/jstl-1.2.jar"/>
|
||||||
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/log4j.jar"/>
|
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/log4j.jar"/>
|
||||||
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/ognl-2.7.3.jar"/>
|
|
||||||
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/slf4j-api-1.7.5.jar"/>
|
|
||||||
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/slf4j-nop-1.7.5.jar"/>
|
|
||||||
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/spring-context-support.jar"/>
|
|
||||||
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/struts2-core-2.1.8.1.jar"/>
|
|
||||||
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/xstream-1.3.jar"/>
|
|
||||||
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/xwork-core-2.1.6.jar"/>
|
|
||||||
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/commons-lang-2.3.jar"/>
|
|
||||||
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/netty-buffer-4.1.0.CR7.jar"/>
|
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/netty-buffer-4.1.0.CR7.jar"/>
|
||||||
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/netty-codec-4.1.0.CR7.jar"/>
|
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/netty-codec-4.1.0.CR7.jar"/>
|
||||||
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/netty-codec-memcache-4.1.0.CR7.jar"/>
|
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/netty-codec-memcache-4.1.0.CR7.jar"/>
|
||||||
@ -46,5 +38,13 @@
|
|||||||
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/netty-handler-proxy-4.1.0.CR7.jar"/>
|
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/netty-handler-proxy-4.1.0.CR7.jar"/>
|
||||||
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/netty-resolver-4.1.0.CR7.jar"/>
|
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/netty-resolver-4.1.0.CR7.jar"/>
|
||||||
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/netty-transport-4.1.0.CR7.jar"/>
|
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/netty-transport-4.1.0.CR7.jar"/>
|
||||||
|
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/ognl-2.7.3.jar"/>
|
||||||
|
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/slf4j-api-1.7.5.jar"/>
|
||||||
|
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/slf4j-nop-1.7.5.jar"/>
|
||||||
|
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/spring-context-support.jar"/>
|
||||||
|
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/struts2-core-2.1.8.1.jar"/>
|
||||||
|
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/xstream-1.3.jar"/>
|
||||||
|
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/xwork-core-2.1.6.jar"/>
|
||||||
|
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/cim-server-sdk-2.1.jar"/>
|
||||||
<classpathentry kind="output" path="WebRoot/WEB-INF/classes"/>
|
<classpathentry kind="output" path="WebRoot/WEB-INF/classes"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
log4j.rootLogger=debug,console, file
|
log4j.rootLogger=info,console, file
|
||||||
|
|
||||||
#----------console----------------
|
#----------console----------------
|
||||||
log4j.appender.console=org.apache.log4j.ConsoleAppender
|
log4j.appender.console=org.apache.log4j.ConsoleAppender
|
||||||
log4j.appender.console.layout=org.apache.log4j.PatternLayout
|
log4j.appender.console.layout=org.apache.log4j.PatternLayout
|
||||||
log4j.appender.console.Target=System.out
|
log4j.appender.console.Target=System.out
|
||||||
log4j.appender.console.layout.ConversionPattern=%C %p %d{yyyy-MM-dd HH:mm:ss}%n%m%n--------------------------------------------------------------------------------------------------------------------------%n
|
log4j.appender.console.layout.ConversionPattern=%C.%M() %p %d{yyyy-MM-dd HH:mm:ss}%n%m%n--------------------------------------------------------------------------------------------------------------------------%n
|
||||||
#----------file----------------
|
#----------file----------------
|
||||||
log4j.appender.file=org.apache.log4j.FileAppender
|
log4j.appender.file=org.apache.log4j.FileAppender
|
||||||
log4j.appender.file.File=cim.log
|
log4j.appender.file.File=cim.log
|
||||||
log4j.appender.file.layout=org.apache.log4j.PatternLayout
|
log4j.appender.file.layout=org.apache.log4j.PatternLayout
|
||||||
log4j.appender.file.layout.ConversionPattern=%C %p %d{yyyy-MM-dd HH\:mm\:ss} - %m%n
|
log4j.appender.console.layout.ConversionPattern=%C.%M() %p %d{yyyy-MM-dd HH:mm:ss}%n%m%n--------------------------------------------------------------------------------------------------------------------------%n
|
||||||
|
|
||||||
|
@ -21,9 +21,7 @@
|
|||||||
<entry key="client_bind">
|
<entry key="client_bind">
|
||||||
<bean class="com.farsunset.cim.handler.BindHandler" />
|
<bean class="com.farsunset.cim.handler.BindHandler" />
|
||||||
</entry>
|
</entry>
|
||||||
<entry key="client_logout">
|
|
||||||
<bean class="com.farsunset.cim.handler.LogoutHandler" />
|
|
||||||
</entry>
|
|
||||||
<entry key="client_cimsession_closed">
|
<entry key="client_cimsession_closed">
|
||||||
<bean class="com.farsunset.cim.handler.SessionClosedHandler"/>
|
<bean class="com.farsunset.cim.handler.SessionClosedHandler"/>
|
||||||
</entry>
|
</entry>
|
||||||
|
Binary file not shown.
@ -1,37 +0,0 @@
|
|||||||
/**
|
|
||||||
* probject:cim
|
|
||||||
* @version 2.0
|
|
||||||
*
|
|
||||||
* @author 3979434@qq.com
|
|
||||||
*/
|
|
||||||
package com.farsunset.cim.handler;
|
|
||||||
|
|
||||||
import com.farsunset.cim.sdk.server.constant.CIMConstant;
|
|
||||||
import com.farsunset.cim.sdk.server.handler.CIMRequestHandler;
|
|
||||||
import com.farsunset.cim.sdk.server.model.ReplyBody;
|
|
||||||
import com.farsunset.cim.sdk.server.model.SentBody;
|
|
||||||
import com.farsunset.cim.sdk.server.session.CIMSession;
|
|
||||||
import com.farsunset.cim.sdk.server.session.DefaultSessionManager;
|
|
||||||
import com.farsunset.cim.util.ContextHolder;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 退出连接实现
|
|
||||||
*/
|
|
||||||
public class LogoutHandler implements CIMRequestHandler {
|
|
||||||
|
|
||||||
public ReplyBody process(CIMSession ios, SentBody message) {
|
|
||||||
|
|
||||||
|
|
||||||
DefaultSessionManager sessionManager = ((DefaultSessionManager) ContextHolder.getBean("CIMSessionManager"));
|
|
||||||
|
|
||||||
String account =ios.getAttribute(CIMConstant.SESSION_KEY).toString();
|
|
||||||
ios.removeAttribute(CIMConstant.SESSION_KEY);
|
|
||||||
ios.closeNow();
|
|
||||||
sessionManager.remove(account);
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -26,15 +26,12 @@ public class SessionClosedHandler implements CIMRequestHandler {
|
|||||||
|
|
||||||
public ReplyBody process(CIMSession ios, SentBody message) {
|
public ReplyBody process(CIMSession ios, SentBody message) {
|
||||||
|
|
||||||
DefaultSessionManager sessionManager = ((DefaultSessionManager) ContextHolder.getBean("CIMSessionManager"));
|
DefaultSessionManager sessionManager = ((DefaultSessionManager) ContextHolder.getBean("CIMSessionManager"));
|
||||||
|
|
||||||
if(ios.getAttribute(CIMConstant.SESSION_KEY)==null)
|
String account =ios.getAttribute(CIMConstant.SESSION_KEY).toString();
|
||||||
{
|
ios.removeAttribute(CIMConstant.SESSION_KEY);
|
||||||
return null;
|
ios.closeNow();
|
||||||
}
|
sessionManager.remove(account);
|
||||||
|
|
||||||
String account = ios.getAttribute(CIMConstant.SESSION_KEY).toString();
|
|
||||||
sessionManager.remove(account);
|
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
log4j.rootLogger=debug,console, file
|
log4j.rootLogger=info,console, file
|
||||||
|
|
||||||
#----------console----------------
|
#----------console----------------
|
||||||
log4j.appender.console=org.apache.log4j.ConsoleAppender
|
log4j.appender.console=org.apache.log4j.ConsoleAppender
|
||||||
log4j.appender.console.layout=org.apache.log4j.PatternLayout
|
log4j.appender.console.layout=org.apache.log4j.PatternLayout
|
||||||
log4j.appender.console.Target=System.out
|
log4j.appender.console.Target=System.out
|
||||||
log4j.appender.console.layout.ConversionPattern=%C %p %d{yyyy-MM-dd HH:mm:ss}%n%m%n--------------------------------------------------------------------------------------------------------------------------%n
|
log4j.appender.console.layout.ConversionPattern=%C.%M() %p %d{yyyy-MM-dd HH:mm:ss}%n%m%n--------------------------------------------------------------------------------------------------------------------------%n
|
||||||
#----------file----------------
|
#----------file----------------
|
||||||
log4j.appender.file=org.apache.log4j.FileAppender
|
log4j.appender.file=org.apache.log4j.FileAppender
|
||||||
log4j.appender.file.File=cim.log
|
log4j.appender.file.File=cim.log
|
||||||
log4j.appender.file.layout=org.apache.log4j.PatternLayout
|
log4j.appender.file.layout=org.apache.log4j.PatternLayout
|
||||||
log4j.appender.file.layout.ConversionPattern=%C %p %d{yyyy-MM-dd HH\:mm\:ss} - %m%n
|
log4j.appender.file.layout.ConversionPattern=%C.%M() %p %d{yyyy-MM-dd HH:mm:ss}%n%m%n--------------------------------------------------------------------------------------------------------------------------%n
|
||||||
|
|
||||||
|
@ -21,9 +21,7 @@
|
|||||||
<entry key="client_bind">
|
<entry key="client_bind">
|
||||||
<bean class="com.farsunset.cim.handler.BindHandler" />
|
<bean class="com.farsunset.cim.handler.BindHandler" />
|
||||||
</entry>
|
</entry>
|
||||||
<entry key="client_logout">
|
|
||||||
<bean class="com.farsunset.cim.handler.LogoutHandler" />
|
|
||||||
</entry>
|
|
||||||
<entry key="client_cimsession_closed">
|
<entry key="client_cimsession_closed">
|
||||||
<bean class="com.farsunset.cim.handler.SessionClosedHandler"/>
|
<bean class="com.farsunset.cim.handler.SessionClosedHandler"/>
|
||||||
</entry>
|
</entry>
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="com.farsunset.ichat.example"
|
package="com.farsunset.ichat.example"
|
||||||
android:versionCode="2"
|
android:versionCode="3"
|
||||||
android:versionName="2.0.0" >
|
android:versionName="2.1.0" >
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||||
|
BIN
cim_for_netty/client-mchat-android/libs/cim-android-sdk-2.1.jar
Normal file
BIN
cim_for_netty/client-mchat-android/libs/cim-android-sdk-2.1.jar
Normal file
Binary file not shown.
Binary file not shown.
@ -6,29 +6,14 @@
|
|||||||
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
|
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
|
||||||
|
|
||||||
-dontwarn
|
-dontwarn
|
||||||
-keep public class com.adview.** {*;}
|
-keep public class io.netty.** {*;}
|
||||||
-keeppackagenames com.madhouse.android.ads
|
-keep public class com.farsunset.cim.sdk.android.model.** {*;}
|
||||||
-keepclassmembers class * {public *;}
|
|
||||||
-keep public class com.wqmobile.sdk.** {*;}
|
|
||||||
-keep public class * {public *;}
|
|
||||||
-keep public class com.adwo.adsdk.AdwoAdBrowserActivity
|
|
||||||
-keep public class com.wooboo.** {*;}
|
|
||||||
-keep public class cn.aduu.adsdk.**{*;}
|
|
||||||
-keep class net.youmi.android.** {*;}
|
|
||||||
-keep public class * extends android.app.Activity
|
-keep public class * extends android.app.Activity
|
||||||
-keep public class * extends android.app.Application
|
-keep public class * extends android.app.Application
|
||||||
-keep public class * extends android.app.Service
|
-keep public class * extends android.app.Service
|
||||||
-keep public class * extends android.content.BroadcastReceiver
|
-keep public class * extends android.content.BroadcastReceiver
|
||||||
-keep public class * extends android.content.ContentProvider
|
-keep public class * extends android.content.ContentProvider
|
||||||
-keep public class com.android.vending.licensing.ILicensingService
|
|
||||||
-keep public class MobWin.*
|
|
||||||
-keep public class MobWin.cnst.*
|
|
||||||
-keep class com.tencent.lbsapi.*
|
|
||||||
-keep class com.tencent.lbsapi.core.*
|
|
||||||
-keep class LBSAPIProtocol.*
|
|
||||||
-keep class com.tencent.lbsapi.core.QLBSJNI {
|
|
||||||
*;
|
|
||||||
}
|
|
||||||
-keepclasseswithmembernames class * {
|
-keepclasseswithmembernames class * {
|
||||||
native <methods>;
|
native <methods>;
|
||||||
}
|
}
|
||||||
|
@ -8,4 +8,4 @@
|
|||||||
# project structure.
|
# project structure.
|
||||||
|
|
||||||
# Project target.
|
# Project target.
|
||||||
target=android-19
|
target=android-22
|
||||||
|
@ -9,7 +9,7 @@ package com.farsunset.ichat.example.app;
|
|||||||
public interface Constant {
|
public interface Constant {
|
||||||
|
|
||||||
//服务端IP地址
|
//服务端IP地址
|
||||||
public static final String CIM_SERVER_HOST = "192.168.2.3";
|
public static final String CIM_SERVER_HOST = "192.168.191.1";
|
||||||
|
|
||||||
//服务端web地址
|
//服务端web地址
|
||||||
public static final String SERVER_URL = "http://"+CIM_SERVER_HOST+":8080/cim-server";
|
public static final String SERVER_URL = "http://"+CIM_SERVER_HOST+":8080/cim-server";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user