mirror of
https://gitee.com/farsunset/cim.git
synced 2025-07-24 08:41:46 +08:00
修改拼写错
This commit is contained in:
parent
6decfb4992
commit
9d8eefcc49
@ -103,7 +103,7 @@
|
||||
<workItem from="1579076046499" duration="14355000" />
|
||||
<workItem from="1579226829168" duration="8852000" />
|
||||
<workItem from="1583472574255" duration="526000" />
|
||||
<workItem from="1583473153031" duration="14749000" />
|
||||
<workItem from="1583473153031" duration="15009000" />
|
||||
</task>
|
||||
<servers />
|
||||
</component>
|
||||
@ -127,46 +127,46 @@
|
||||
<screen x="0" y="0" width="1920" height="1040" />
|
||||
</state>
|
||||
<state x="690" y="218" key="FileChooserDialogImpl/0.0.1920.1040@0.0.1920.1040" timestamp="1579230010253" />
|
||||
<state width="1870" height="565" key="GridCell.Tab.0.bottom" timestamp="1583566851136">
|
||||
<state width="1870" height="403" key="GridCell.Tab.0.bottom" timestamp="1583567568644">
|
||||
<screen x="0" y="23" width="1920" height="1057" />
|
||||
</state>
|
||||
<state width="1867" height="615" key="GridCell.Tab.0.bottom/0.0.1920.1040@0.0.1920.1040" timestamp="1579243696749" />
|
||||
<state width="1870" height="565" key="GridCell.Tab.0.bottom/0.23.1920.1057@0.23.1920.1057" timestamp="1583566851136" />
|
||||
<state width="1870" height="565" key="GridCell.Tab.0.center" timestamp="1583566851135">
|
||||
<state width="1870" height="403" key="GridCell.Tab.0.bottom/0.23.1920.1057@0.23.1920.1057" timestamp="1583567568644" />
|
||||
<state width="1870" height="403" key="GridCell.Tab.0.center" timestamp="1583567568644">
|
||||
<screen x="0" y="23" width="1920" height="1057" />
|
||||
</state>
|
||||
<state width="1867" height="615" key="GridCell.Tab.0.center/0.0.1920.1040@0.0.1920.1040" timestamp="1579243696749" />
|
||||
<state width="1870" height="565" key="GridCell.Tab.0.center/0.23.1920.1057@0.23.1920.1057" timestamp="1583566851135" />
|
||||
<state width="1870" height="565" key="GridCell.Tab.0.left" timestamp="1583566851135">
|
||||
<state width="1870" height="403" key="GridCell.Tab.0.center/0.23.1920.1057@0.23.1920.1057" timestamp="1583567568644" />
|
||||
<state width="1870" height="403" key="GridCell.Tab.0.left" timestamp="1583567568643">
|
||||
<screen x="0" y="23" width="1920" height="1057" />
|
||||
</state>
|
||||
<state width="1867" height="615" key="GridCell.Tab.0.left/0.0.1920.1040@0.0.1920.1040" timestamp="1579243696749" />
|
||||
<state width="1870" height="565" key="GridCell.Tab.0.left/0.23.1920.1057@0.23.1920.1057" timestamp="1583566851135" />
|
||||
<state width="1870" height="565" key="GridCell.Tab.0.right" timestamp="1583566851136">
|
||||
<state width="1870" height="403" key="GridCell.Tab.0.left/0.23.1920.1057@0.23.1920.1057" timestamp="1583567568643" />
|
||||
<state width="1870" height="403" key="GridCell.Tab.0.right" timestamp="1583567568644">
|
||||
<screen x="0" y="23" width="1920" height="1057" />
|
||||
</state>
|
||||
<state width="1867" height="615" key="GridCell.Tab.0.right/0.0.1920.1040@0.0.1920.1040" timestamp="1579243696749" />
|
||||
<state width="1870" height="565" key="GridCell.Tab.0.right/0.23.1920.1057@0.23.1920.1057" timestamp="1583566851136" />
|
||||
<state width="1870" height="565" key="GridCell.Tab.1.bottom" timestamp="1583566851137">
|
||||
<state width="1870" height="403" key="GridCell.Tab.0.right/0.23.1920.1057@0.23.1920.1057" timestamp="1583567568644" />
|
||||
<state width="1870" height="565" key="GridCell.Tab.1.bottom" timestamp="1583567566487">
|
||||
<screen x="0" y="23" width="1920" height="1057" />
|
||||
</state>
|
||||
<state width="1867" height="615" key="GridCell.Tab.1.bottom/0.0.1920.1040@0.0.1920.1040" timestamp="1579243696751" />
|
||||
<state width="1870" height="565" key="GridCell.Tab.1.bottom/0.23.1920.1057@0.23.1920.1057" timestamp="1583566851137" />
|
||||
<state width="1870" height="565" key="GridCell.Tab.1.center" timestamp="1583566851136">
|
||||
<state width="1870" height="565" key="GridCell.Tab.1.bottom/0.23.1920.1057@0.23.1920.1057" timestamp="1583567566487" />
|
||||
<state width="1870" height="565" key="GridCell.Tab.1.center" timestamp="1583567566486">
|
||||
<screen x="0" y="23" width="1920" height="1057" />
|
||||
</state>
|
||||
<state width="1867" height="615" key="GridCell.Tab.1.center/0.0.1920.1040@0.0.1920.1040" timestamp="1579243696750" />
|
||||
<state width="1870" height="565" key="GridCell.Tab.1.center/0.23.1920.1057@0.23.1920.1057" timestamp="1583566851136" />
|
||||
<state width="1870" height="565" key="GridCell.Tab.1.left" timestamp="1583566851136">
|
||||
<state width="1870" height="565" key="GridCell.Tab.1.center/0.23.1920.1057@0.23.1920.1057" timestamp="1583567566486" />
|
||||
<state width="1870" height="565" key="GridCell.Tab.1.left" timestamp="1583567566486">
|
||||
<screen x="0" y="23" width="1920" height="1057" />
|
||||
</state>
|
||||
<state width="1867" height="615" key="GridCell.Tab.1.left/0.0.1920.1040@0.0.1920.1040" timestamp="1579243696749" />
|
||||
<state width="1870" height="565" key="GridCell.Tab.1.left/0.23.1920.1057@0.23.1920.1057" timestamp="1583566851136" />
|
||||
<state width="1870" height="565" key="GridCell.Tab.1.right" timestamp="1583566851137">
|
||||
<state width="1870" height="565" key="GridCell.Tab.1.left/0.23.1920.1057@0.23.1920.1057" timestamp="1583567566486" />
|
||||
<state width="1870" height="565" key="GridCell.Tab.1.right" timestamp="1583567566486">
|
||||
<screen x="0" y="23" width="1920" height="1057" />
|
||||
</state>
|
||||
<state width="1867" height="615" key="GridCell.Tab.1.right/0.0.1920.1040@0.0.1920.1040" timestamp="1579243696751" />
|
||||
<state width="1870" height="565" key="GridCell.Tab.1.right/0.23.1920.1057@0.23.1920.1057" timestamp="1583566851137" />
|
||||
<state width="1870" height="565" key="GridCell.Tab.1.right/0.23.1920.1057@0.23.1920.1057" timestamp="1583567566486" />
|
||||
<state width="1867" height="386" key="GridCell.Tab.2.bottom" timestamp="1579156159339">
|
||||
<screen x="0" y="0" width="1920" height="1040" />
|
||||
</state>
|
||||
|
@ -41,7 +41,6 @@ import java.nio.channels.SocketChannel;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
/*
|
||||
* 连接服务端管理,cim核心处理类,管理连接,以及消息处理
|
||||
@ -54,14 +53,13 @@ class CIMConnectorManager {
|
||||
|
||||
private static final int WRITE_BUFFER_SIZE = 1024;
|
||||
|
||||
private static final int READ_IDLE_TIME = 120 * 1000;
|
||||
|
||||
private static final int CONNECT_TIME_OUT = 10 * 1000;
|
||||
|
||||
/*
|
||||
服务端在连接写空闲120秒的时候发送心跳请求给客户端,所以客户端在空闲150秒后都没有收到任何数据,则关闭链接,并重新创建
|
||||
*/
|
||||
private static final int CONNECT_ALIVE_TIME_OUT = 150 * 1000;
|
||||
|
||||
private static final AtomicLong LAST_READ_TIME = new AtomicLong(0);
|
||||
|
||||
private static final CIMLogger LOGGER = CIMLogger.getLogger();
|
||||
|
||||
private static final HandlerThread IDLE_HANDLER_THREAD = new HandlerThread("READ-IDLE", Process.THREAD_PRIORITY_BACKGROUND);
|
||||
@ -72,7 +70,6 @@ class CIMConnectorManager {
|
||||
|
||||
private final ByteBuffer headerBuffer = ByteBuffer.allocate(CIMConstant.DATA_HEADER_LENGTH);
|
||||
|
||||
|
||||
private final ExecutorService workerExecutor = Executors.newFixedThreadPool(1, r -> new Thread(r, "worker-"));
|
||||
|
||||
private final ExecutorService bossExecutor = Executors.newFixedThreadPool(1, r -> new Thread(r, "boss-"));
|
||||
@ -88,7 +85,6 @@ class CIMConnectorManager {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
|
||||
public synchronized static CIMConnectorManager getManager(Context context) {
|
||||
|
||||
if (manager == null) {
|
||||
@ -214,8 +210,6 @@ class CIMConnectorManager {
|
||||
private void sessionCreated() {
|
||||
LOGGER.sessionCreated(socketChannel);
|
||||
|
||||
LAST_READ_TIME.set(System.currentTimeMillis());
|
||||
|
||||
Intent intent = new Intent();
|
||||
intent.setPackage(context.getPackageName());
|
||||
intent.setAction(CIMConstant.IntentAction.ACTION_CONNECT_FINISHED);
|
||||
@ -227,8 +221,6 @@ class CIMConnectorManager {
|
||||
|
||||
idleHandler.removeMessages(0);
|
||||
|
||||
LAST_READ_TIME.set(0);
|
||||
|
||||
LOGGER.sessionClosed(socketChannel);
|
||||
|
||||
Intent intent = new Intent();
|
||||
@ -242,12 +234,7 @@ class CIMConnectorManager {
|
||||
|
||||
LOGGER.sessionIdle(socketChannel);
|
||||
|
||||
/*
|
||||
* 用于解决,wifi情况下。偶而路由器与服务器断开连接时,客户端并没及时收到关闭事件 导致这样的情况下当前连接无效也不会重连的问题
|
||||
*/
|
||||
if (System.currentTimeMillis() - LAST_READ_TIME.get() >= CONNECT_ALIVE_TIME_OUT) {
|
||||
closeSession();
|
||||
}
|
||||
closeSession();
|
||||
}
|
||||
|
||||
|
||||
@ -313,20 +300,17 @@ class CIMConnectorManager {
|
||||
|
||||
private void handleConnectedEvent() {
|
||||
|
||||
closeCountDown();
|
||||
|
||||
sessionCreated();
|
||||
|
||||
idleHandler.sendEmptyMessageDelayed(0, READ_IDLE_TIME);
|
||||
}
|
||||
|
||||
private void handleSocketReadEvent() throws IOException {
|
||||
|
||||
onMessageDecodeFinished(messageDecoder.doDecode(headerBuffer,socketChannel));
|
||||
closeCountDown();
|
||||
|
||||
markLastReadTime();
|
||||
|
||||
}
|
||||
|
||||
private void onMessageDecodeFinished(Object message){
|
||||
Object message = messageDecoder.doDecode(headerBuffer,socketChannel);
|
||||
|
||||
LOGGER.messageReceived(socketChannel, message);
|
||||
|
||||
@ -336,17 +320,15 @@ class CIMConnectorManager {
|
||||
}
|
||||
|
||||
this.messageReceived(message);
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void markLastReadTime() {
|
||||
|
||||
LAST_READ_TIME.set(System.currentTimeMillis());
|
||||
private void closeCountDown() {
|
||||
|
||||
idleHandler.removeMessages(0);
|
||||
|
||||
idleHandler.sendEmptyMessageDelayed(0, READ_IDLE_TIME);
|
||||
|
||||
idleHandler.sendEmptyMessageDelayed(0, CONNECT_ALIVE_TIME_OUT);
|
||||
}
|
||||
|
||||
}
|
||||
|
Binary file not shown.
Binary file not shown.
@ -15,7 +15,7 @@
|
||||
android:label="@string/app_name"
|
||||
android:theme="@style/GlobeTheme">
|
||||
<activity
|
||||
android:name=".ui.SplanshActivity"
|
||||
android:name=".ui.SplashActivity"
|
||||
android:alwaysRetainTaskState="true"
|
||||
android:screenOrientation="portrait">
|
||||
<intent-filter>
|
||||
|
@ -24,7 +24,7 @@ package com.farsunset.ichat.example.app;
|
||||
public interface Constant {
|
||||
|
||||
//服务端IP地址
|
||||
String CIM_SERVER_HOST = "192.168.2.103";
|
||||
String CIM_SERVER_HOST = "192.168.22.103";
|
||||
|
||||
//注意,这里的端口不是tomcat的端口,没改动就使用默认的23456
|
||||
int CIM_SERVER_PORT = 23456;
|
||||
|
@ -22,11 +22,7 @@
|
||||
package com.farsunset.ichat.example.ui;
|
||||
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.Network;
|
||||
import android.net.NetworkRequest;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.RequiresApi;
|
||||
@ -35,13 +31,12 @@ import android.view.animation.AlphaAnimation;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.farsunset.cim.sdk.android.CIMPushManager;
|
||||
import com.farsunset.cim.sdk.android.constant.CIMConstant;
|
||||
import com.farsunset.ichat.example.BuildConfig;
|
||||
import com.farsunset.ichat.example.R;
|
||||
import com.farsunset.ichat.example.app.CIMMonitorActivity;
|
||||
import com.farsunset.ichat.example.app.Constant;
|
||||
|
||||
public class SplanshActivity extends CIMMonitorActivity {
|
||||
public class SplashActivity extends CIMMonitorActivity {
|
||||
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||
@ -53,7 +48,7 @@ public class SplanshActivity extends CIMMonitorActivity {
|
||||
CIMPushManager.setLoggerEnable(this, BuildConfig.DEBUG);
|
||||
//连接服务端
|
||||
|
||||
CIMPushManager.connect(SplanshActivity.this, Constant.CIM_SERVER_HOST, Constant.CIM_SERVER_PORT);
|
||||
CIMPushManager.connect(SplashActivity.this, Constant.CIM_SERVER_HOST, Constant.CIM_SERVER_PORT);
|
||||
|
||||
|
||||
final View view = View.inflate(this, R.layout.activity_splansh, null);
|
||||
@ -68,7 +63,7 @@ public class SplanshActivity extends CIMMonitorActivity {
|
||||
@Override
|
||||
public void onConnectFinished(boolean autoBind) {
|
||||
|
||||
Intent intent = new Intent(SplanshActivity.this, LoginActivity.class);
|
||||
Intent intent = new Intent(SplashActivity.this, LoginActivity.class);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user